title: LinearLayout weightsum not working with image
body: <p>I have a <code>LinearLayout</code> with <code>weightSum</code> 10 which has 2 child <code>LinearLayout</code> with <code>layout_weight</code> 4 and 6. It works fine when background is color or nothing. But the problem occurs when I set a background image. What can be the problem and solution?</p>
  
  <p>Working code:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
  
      android:weightSum="10" &gt;
  
   &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dip"
          android:layout_weight="4"
          android:background="@color/Blue"
   &gt;
  
      &lt;/LinearLayout&gt;
  
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dip"
          android:layout_weight="6"
          android:background="@color/new_back"
          android:orientation="vertical"
          android:weightSum="10" &gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="5"
              android:gravity="center"
              android:orientation="horizontal"
              android:weightSum="99" &gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnCustomers"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/customer" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Chemist"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnOrder"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/order" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Order"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnItemStatus"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/item_status" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Item Status"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="5"
              android:gravity="center"
              android:orientation="horizontal"
              android:weightSum="99" &gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnNotification"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/notification" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Notification"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnAttendance"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/attendance" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Attendance"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnExpenceClaim"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/expence_clain" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Exp. Claim"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NNOGZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NNOGZ.png" alt=""></a></p>
  
  <p>Problematic code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
  
      android:weightSum="10" &gt;
  
   &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dip"
          android:layout_weight="4"
          android:background="@drawable/top_menu"
   &gt;
  
      &lt;/LinearLayout&gt;
  
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dip"
          android:layout_weight="6"
          android:background="@color/new_back"
          android:orientation="vertical"
          android:weightSum="10" &gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="5"
              android:gravity="center"
              android:orientation="horizontal"
              android:weightSum="99" &gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnCustomers"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/customer" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Chemist"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnOrder"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/order" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Order"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnItemStatus"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/item_status" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Item Status"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="5"
              android:gravity="center"
              android:orientation="horizontal"
              android:weightSum="99" &gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnNotification"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/notification" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Notification"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnAttendance"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/attendance" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Attendance"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_weight="33"
                  android:gravity="center"
                  android:orientation="vertical" &gt;
  
                  &lt;ImageView
                      android:id="@+id/idbtnExpenceClaim"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:src="@drawable/expence_clain" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:text="Exp. Claim"
                      android:textColor="#000000" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hkxys.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hkxys.png" alt=""></a></p>