title: How to set the linear layout width in a HorizontalScrollView?
body: <p>I have a <code>LinearLayout</code> (let's call it <strong>A</strong>)that it's width set to <code>fill_parent</code>, this layout contains a bunch of another <code>LinearLayouts</code>(let's call them <strong>B</strong>), I want the screen only display <em>four</em> <strong>B</strong>'s so i assigned the <code>weight_sum</code> of <strong>A</strong> as <code>4</code> and assigned each one of <strong>B</strong>'s as <code>1</code>, now i want to add a <code>HorizontalScrollView</code> so that if i have like 6 layouts of <strong>B</strong> only four will be displayed and the other two will be scrolled. I build this <code>HorizontalScrollView</code> to contain the <strong>A</strong> layout(as the <code>HorizontalScrollView</code> should has only one direct child), now the fill_parent width i add to the layout <strong>A</strong> is ruined as it now obeys the <code>HorizontalScrollView</code> so the <strong>B</strong> layouts width is ruined also, take a look at the following figures:</p>
  
  <p>-- <em>yellow</em> : the Whole Screen.</p>
  
  <p>-- <em>green</em> : <strong>A</strong> Layout.</p>
  
  <p>-- <em>red</em> : <strong>B</strong> Layout.</p>
  
  <p><strong>The result I got:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/zUiT1.png" alt="enter image description here"></p>
  
  <p><strong>The result i suppose to get:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/kK3VE.png" alt="enter image description here"></p>
  
  <p>I'm tried to set the width of both <code>HorizontalScrollView</code> and the Layout <strong>A</strong> to <code>fill_parent</code> and/or <code>wrap_content</code> but nothing works with me.</p>
  
  <p>My <strong>XML</strong> Code:</p>
  
  <pre><code>      &lt;HorizontalScrollView 
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content" &gt;
           &lt;LinearLayout 
                         android:id="@+id/A"
                         android:layout_width="fill_parent"
                         android:layout_height="wrap_content"
                         android:orientation="horizontal"
                         android:weightSum="4" &gt;
  
              &lt;LinearLayout
                      android:id="@+id/B1"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:orientation="vertical"
                      android:weightSum="1" &gt;
  
                      &lt;LinearLayout
                          android:id="@+id/icon1"
                          android:layout_width="wrap_content"
                          android:layout_height="0dp"
                          android:layout_marginLeft="10dp"
                          android:layout_marginRight="5dp"
                          android:layout_marginTop="15dp"
                          android:layout_weight="0.5"
                          android:background="@drawable/ac_overlay"
                          android:orientation="horizontal"
                          android:tag="normal" &gt;
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
                          android:id="@+id/icon2"
                          android:layout_width="wrap_content"
                          android:layout_height="0dp"
                          android:layout_marginLeft="10dp"
                          android:layout_marginRight="5dp"
                          android:layout_marginTop="15dp"
                          android:layout_weight="0.5"
                          android:background="@drawable/ac_overlay"
                          android:orientation="horizontal"
                          android:tag="normal" &gt;
                      &lt;/LinearLayout&gt;
                  &lt;/LinearLayout&gt;
               &lt;LinearLayout
                      android:id="@+id/B2"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:orientation="vertical"
                      android:weightSum="1" &gt;
  
                      &lt;LinearLayout
                          android:id="@+id/icon3"
                          android:layout_width="wrap_content"
                          android:layout_height="0dp"
                          android:layout_marginLeft="10dp"
                          android:layout_marginRight="5dp"
                          android:layout_marginTop="15dp"
                          android:layout_weight="0.5"
                          android:background="@drawable/ac_overlay"
                          android:orientation="horizontal"
                          android:tag="normal" &gt;
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
                          android:id="@+id/icon4"
                          android:layout_width="wrap_content"
                          android:layout_height="0dp"
                          android:layout_marginLeft="10dp"
                          android:layout_marginRight="5dp"
                          android:layout_marginTop="15dp"
                          android:layout_weight="0.5"
                          android:background="@drawable/ac_overlay"
                          android:orientation="horizontal"
                          android:tag="normal" &gt;
                      &lt;/LinearLayout&gt;
                    &lt;/LinearLayout&gt;
                   &lt;/LinearLayout&gt;
      &lt;/HorizontalScrollView&gt;
  </code></pre>