title: Why does my relative layout occupy full screen width
body: <p>Why does my relative layout occupy full screen width</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:background=&quot;#f00&quot;
      &gt;
      &lt;Button  
          android:id=&quot;@+id/Button01&quot;  
          android:text=&quot;Press Here&quot;  
          android:layout_alignParentRight=&quot;true&quot; 
          android:layout_width=&quot;wrap_content&quot;   
          android:layout_height=&quot;wrap_content&quot;&gt;&lt;/Button&gt; 
       &lt;Button  
          android:id=&quot;@+id/Button02&quot;  
          android:text=&quot;02&quot;  
          android:layout_alignParentLeft=&quot;true&quot; 
          android:layout_width=&quot;wrap_content&quot;   
          android:layout_height=&quot;wrap_content&quot;&gt;&lt;/Button&gt;  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>I have specified the relative layout to &quot;wrap_content&quot;, then why does it occupy full screen space. Out put is same even if i say android:layout_width=&quot;fill_parent&quot;. <img src="https://i.stack.imgur.com/Pvdk6.jpg" alt="Enlighten" /></p>
  <p>Enlighten me please!</p>
  <p>EDIT : I think i was not very clear with my question earlier. Apologies for that.
  When I have 2 child views in a relative layout and one of them is left aligned to parent and other is right aligned and relative layouts width is WRAP_CONTENT then I expected the layouts width to be just the sum of width of 2 buttons (isn't that's what WRAP_CONTENT means??). I know there are other ways of achieving the UI im looking for but Im just trying to understand these relative layout tags properly.</p>
  <p>EDIT 2: I have experimented a bit and it looks like if we using Layout_AlighParentRight with its parent's width as WRAP_CONTENT then the upper layout width is used for calculation (like few answers pointed out below). But we are using just the Layout_alignParentLeft then it works as expected and layout width is not extending to the complete screen. Thanks for the help folks!</p>