title: How to provide proper weight to align the view properly in table android
body: <p>I am using a heading where I need to place seven headings with correponding values.</p>
  
  <p>But the first column has image with two text which is troubling to fit inside the table.</p>
  
  <p>I given weight but it's troubling in aligning with other views. Everytime whenever i change one view say for eg: 5th column, sixth column gets rearranged. </p>
  
  <p>I used a list followed by row. </p>
  
  <p>In the main xml, I used Titles.</p>
  
    
  
  <pre><code>&lt;android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/colorWhite"
      android:isScrollContainer="false"
      android:paddingBottom="20dp"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;!--Profile icon--&gt;
          &lt;include layout="@layout/common_profile_layout" /&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="26dp"
              android:background="@color/colorGrey"&gt;
  
              &lt;TextView
                  android:id="@+id/count_id"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerVertical="true"
                  android:layout_marginLeft="24dp"
                  android:gravity="center"
                  android:text="Laporan Aktivitas"
                  android:textColor="?attr/colorUserGroup" /&gt;
  
              &lt;Button
                  android:id="@+id/dafatar_filter"
                  android:layout_width="72dp"
                  android:layout_height="20dp"
                  android:layout_alignParentRight="true"
                  android:layout_centerHorizontal="true"
                  android:layout_centerVertical="true"
                  android:layout_marginRight="10dp"
                  android:background="@drawable/curve_corner_change_day"
                  android:clickable="true"
                  android:paddingLeft="5dp"
                  android:paddingRight="5dp"
                  android:text="Pilih Tanggal"
                  android:textAllCaps="false"
                  android:textColor="@android:color/white"
                  android:textSize="10sp" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="5dp"
              android:orientation="vertical"&gt;
  
              &lt;TextView
                  android:id="@+id/dateTxt"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_marginLeft="24dp"
                  android:text="06/13/2017"
                  android:textColor="@color/colorBlack"
                  android:textSize="@dimen/text_size_small" /&gt;
  
              &lt;ImageView
                  android:id="@+id/route_plan_about_icon"
                  android:layout_width="16dp"
                  android:layout_height="16dp"
                  android:layout_alignParentRight="true"
                  android:layout_centerHorizontal="true"
                  android:layout_centerVertical="true"
                  android:layout_gravity="right"
                  android:layout_marginBottom="2dp"
                  android:layout_marginRight="22dp"
                  android:layout_marginTop="2dp"
                  android:src="?attr/info_drawable" /&gt;
          &lt;/RelativeLayout&gt;
  // here is where the title starts.
          &lt;LinearLayout
              android:id="@+id/rel1"
              android:layout_width="match_parent"
              android:layout_height="33dp"
              android:layout_below="@+id/totalId"
              android:layout_marginTop="14dp"
              android:background="@drawable/nbd_title"
              android:gravity="center_vertical"
              android:weightSum="6"&gt;
  
              &lt;TextView
                  android:id="@+id/siteId"
                  android:layout_width="35dp"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_marginLeft="10dp"
                  android:layout_weight="1.2"
                  android:text="Total"
                  android:textSize="12sp" /&gt;
  
              &lt;TextView
                  android:id="@+id/site"
                  android:layout_width="72dp"
                  android:layout_height="wrap_content"
                  android:layout_weight="1.0"
                  android:gravity="center"
                  android:text="XXXXX"
                  android:textSize="12sp" /&gt;
  
              &lt;TextView
                  android:id="@+id/twoG"
                  android:layout_width="20dp"
                  android:layout_height="wrap_content"
                  android:layout_weight="0.65"
                  android:gravity="center"
                  android:text="XXX"
                  android:textSize="12sp" /&gt;
  
              &lt;TextView
                  android:id="@+id/threeG"
                  android:layout_width="20dp"
                  android:layout_height="wrap_content"
                  android:layout_weight=".65"
                  android:gravity="center"
                  android:text="XXX"
                  android:textSize="12sp" /&gt;
  
              &lt;TextView
                  android:id="@+id/fourG"
                  android:layout_width="20dp"
                  android:layout_height="wrap_content"
                  android:layout_weight=".65"
                  android:gravity="center"
                  android:text="XXX"
                  android:textSize="12sp" /&gt;
  
              &lt;TextView
                  android:id="@+id/retailerId"
                  android:layout_width="35dp"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:gravity="center"
                  android:text="XXX"
                  android:textSize="12sp" /&gt;
  
              &lt;TextView
                  android:id="@+id/idealId"
                  android:layout_width="35dp"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:gravity="center"
                  android:text="XXX"
                  android:textSize="12sp" /&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;FrameLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_below="@+id/rel1"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:weightSum="6"&gt;
  
                  &lt;View
                      android:layout_width="72dp"
                      android:layout_height="match_parent"
                      android:layout_weight="1.2"
                      android:background="@color/colorLightGray" /&gt;
  
                  &lt;View
                      android:layout_width="30dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1" /&gt;
  
                  &lt;View
                      android:layout_width="20dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="0.65"
                      android:background="@color/colorLightGray" /&gt;
  
                  &lt;View
                      android:layout_width="20dp"
                      android:layout_height="wrap_content"
                      android:layout_weight=".65" /&gt;
  
                  &lt;View
                      android:layout_width="20dp"
                      android:layout_height="wrap_content"
                      android:layout_weight=".65"
                      android:background="@color/colorLightGray" /&gt;
  
                  &lt;View
  
                      android:layout_width="35dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1" /&gt;
  
                  &lt;View
                      android:layout_width="35dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:background="@color/colorLightGray" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;android.support.v7.widget.RecyclerView
                  android:id="@+id/recycleViewIdNbd"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_below="@+id/rel1"
                  android:background="@android:color/transparent"
                  android:paddingTop="18dp" /&gt;
          &lt;/FrameLayout&gt;
  
  
      &lt;/LinearLayout&gt;
  &lt;/android.support.v4.widget.NestedScrollView&gt;
  </code></pre>
  
  <p>then in row.xml:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="50dp"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
          android:gravity="center_vertical"
          android:orientation="horizontal"
          android:weightSum="6"&gt;
  
          &lt;LinearLayout
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:layout_weight="1.9"&gt;
  
  
              &lt;com.hutchison.h3i.newangie.customviews.CircleImageView
                  android:id="@+id/recycle_profile"
                  android:layout_width="30dp"
                  android:layout_height="30dp"
                  android:layout_gravity="center"
                  android:layout_marginLeft="8dp"
                  android:src="@drawable/ic_default_profile" /&gt;
  
              &lt;LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerInParent="true"
                  android:layout_gravity="center"
                  android:layout_marginLeft="6dp"
                  android:orientation="vertical"&gt;
  
                  &lt;TextView
                      android:id="@+id/recycle_txt_acc_num"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:ellipsize="end"
                      android:maxLines="1"
                      android:singleLine="false"
                      android:text="@string/route_plan_default_number"
                      android:textColor="@color/colorBlack"
                      android:textSize="@dimen/text_size_tiny_small_nine" /&gt;
  
                  &lt;TextView
                      android:id="@+id/recycle_txt_acc_name"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:ellipsize="end"
                      android:maxLines="1"
                      android:singleLine="false"
                      android:text="SE A"
                      android:textColor="?attr/colorUserGroup"
                      android:textSize="@dimen/text_size_very_small" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
  
          &lt;TextView
              android:id="@+id/txtretailerId"
              android:layout_width="23dp"
              android:layout_height="wrap_content"
              android:layout_weight="1.7"
              android:gravity="center"
              android:text="XXXXX"
              android:textSize="12sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtidealId"
              android:layout_width="20dp"
              android:layout_height="wrap_content"
              android:layout_weight="0.1"
              android:gravity="center"
              android:text="XXX"
              android:textSize="12sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtidealId_1"
              android:layout_width="20dp"
              android:layout_height="wrap_content"
              android:layout_weight="0.3"
              android:gravity="center"
              android:text="XXX"
              android:textSize="12sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtidealId_2"
              android:layout_width="20dp"
              android:layout_height="wrap_content"
              android:layout_weight="0.3"
              android:gravity="center"
              android:text="XXX"
              android:textSize="12sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtidealId_3"
              android:layout_width="20dp"
              android:layout_height="wrap_content"
              android:layout_weight="0.3"
              android:gravity="center"
              android:text="XXX"
              android:textSize="12sp" /&gt;
  
          &lt;TextView
              android:id="@+id/txtidealId_4"
              android:layout_width="20dp"
              android:layout_height="wrap_content"
              android:layout_weight="1.2"
              android:gravity="center"
              android:text="XXX"
              android:textSize="12sp" /&gt;
      &lt;/LinearLayout&gt;
      &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>But my output looks as ,</p>
  
  <p><a href="https://i.stack.imgur.com/wdJjQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wdJjQ.png" alt="enter image description here"></a></p>
  
  <p>But actual output is,</p>
  
  <p><a href="https://i.stack.imgur.com/bDDIW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bDDIW.png" alt="enter image description here"></a></p>
  
  <p>You can clearly see where in my output, align is getting mismatch and not properly fitting. I tried to align but I couldn't achieve it properly. </p>