title: adding a table layout in linear layout
body: <p>I am trying to add a table inside a linear layout. Inside my linear layout there is <code>textview</code>, <code>spinner</code>. When I try to add a table layout it doesn't align correctly. Below is my code</p>
  <pre><code>&lt;LinearLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/cardLayout&quot;
              android:orientation=&quot;vertical&quot;&gt;
              &lt;TextView
                  android:id=&quot;@+id/textView&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot;Product&quot;
                  android:gravity=&quot;center&quot;
                  android:textStyle=&quot;bold&quot;
                  android:textSize=&quot;18sp&quot;/&gt;
  
              &lt;LinearLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_marginTop=&quot;10sp&quot;
                  android:layout_margin=&quot;10sp&quot;
                  android:orientation=&quot;horizontal&quot;&gt;
  
                  &lt;LinearLayout
                      android:layout_width=&quot;0dp&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_weight=&quot;.5&quot;
                      android:orientation=&quot;vertical&quot;&gt;
  
                      &lt;Spinner
                          android:id=&quot;@+id/product_spinner&quot;
                          android:layout_width=&quot;wrap_content&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_gravity=&quot;center&quot;
                          /&gt;
  
  
                  &lt;/LinearLayout&gt;
  
                  &lt;TableLayout 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:layout_marginTop=&quot;100dp&quot;
                      android:paddingLeft=&quot;10dp&quot;
                      android:paddingRight=&quot;10dp&quot;
                      &gt;
                      &lt;TableRow android:background=&quot;#0079D6&quot; android:padding=&quot;5dp&quot;&gt;
                          &lt;TextView
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;wrap_content&quot;
                              android:layout_weight=&quot;1&quot;
                              android:text=&quot;Product Name&quot; /&gt;
                          &lt;TextView
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;wrap_content&quot;
                              android:layout_weight=&quot;1&quot;
                              android:text=&quot;Sale&quot; /&gt;
                      &lt;/TableRow&gt;
                      &lt;TableRow android:background=&quot;#DAE8FC&quot; android:padding=&quot;5dp&quot;&gt;
  
                          &lt;TextView
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;wrap_content&quot;
                              android:layout_weight=&quot;1&quot;
                              android:text=&quot;&quot; /&gt;
                          &lt;TextView
                              android:layout_width=&quot;wrap_content&quot;
                              android:layout_height=&quot;wrap_content&quot;
                              android:layout_weight=&quot;1&quot;
                              android:text=&quot;&quot; /&gt;
                      &lt;/TableRow&gt;
                  &lt;/TableLayout&gt;
  
              &lt;/LinearLayout&gt;
  
          &lt;/LinearLayout&gt;
  </code></pre>
  <p><strong>Output</strong></p>
  <p><a href="https://i.stack.imgur.com/dA7yC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dA7yC.png" alt="enter image description here" /></a></p>
  <p><strong>Expected Output</strong></p>
  <p><a href="https://i.stack.imgur.com/cHBUR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cHBUR.png" alt="enter image description here" /></a></p>
  <p>I must be missing something that I don't know. How  can I align them equally just  like in the above image</p>
  <p>Any help would be highly appreciated.</p>