title: Android: Allow margin/padding in TableLayout to give some separation between widgets
body: <p>I have defined six buttons in TableLayout as:- </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="10dp"
  android:shrinkColumns="*"
  android:stretchColumns="*" &gt;
  
  &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      android:gravity="center" &gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  &lt;/TableRow&gt;
  
  &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1" &gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:padding="5dp"
          android:text="Btn1" /&gt;
  &lt;/TableRow&gt;
  
  &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1" &gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  &lt;/TableRow&gt;
  
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p><strong>whose display is like this:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/vUzdkl.png" alt="enter image description here"></p>
  
  <p>here I want separation between all these buttons. When I apply padding or margin then the button which is in right side not fit into the screen and some portion is cut.</p>
  
  <p>Here I given padding 20 to the first row and margin 20 to the second row then it looks like:-</p>
  
  <p><img src="https://i.stack.imgur.com/2vFcdl.png" alt="enter image description here"></p>
  
  <p>code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="10dp"
  android:shrinkColumns="*"
  android:stretchColumns="*" &gt;
  
  &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      android:padding="20dp" &gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  &lt;/TableRow&gt;
  
  &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      android:layout_margin="20dp" &gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:padding="5dp"
          android:text="Btn1" /&gt;
  &lt;/TableRow&gt;
  
  &lt;TableRow
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1" &gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  
      &lt;Button
          style="@style/CustomStyleButton2"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_span="1"
          android:text="Btn1" /&gt;
  &lt;/TableRow&gt;
  
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p><strong>How to solve this issue?</strong></p>
  
  <p>Style:-</p>
  
  <pre><code>&lt;style name="CustomStyleButton2" parent="@android:style/Widget.Button"&gt;
      &lt;item name="android:textSize"&gt;16sp&lt;/item&gt;
      &lt;item name="android:textStyle"&gt;bold&lt;/item&gt;
      &lt;item name="android:textColor"&gt;#dedfdc&lt;/item&gt;
      &lt;item name="android:gravity"&gt;center&lt;/item&gt;
      &lt;item name="android:shadowColor"&gt;#000000&lt;/item&gt;
      &lt;item name="android:shadowDx"&gt;1&lt;/item&gt;
      &lt;item name="android:shadowDy"&gt;1&lt;/item&gt;
      &lt;item name="android:shadowRadius"&gt;0.6&lt;/item&gt;
      &lt;item name="android:background"&gt;@drawable/custom_button2&lt;/item&gt;
      &lt;item name="android:padding"&gt;10dip&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>background:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item android:state_pressed="true"&gt;
          &lt;shape&gt;
              &lt;solid android:color="#151515" /&gt;
              &lt;stroke android:width="1dp" android:color="#FFFFFF" /&gt;
              &lt;corners android:radius="3dp" /&gt;
              &lt;padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;shape&gt;
              &lt;gradient android:angle="270" android:endColor="#2E2E2E" android:startColor="#585858" /&gt;
              &lt;stroke android:width="1dp" android:color="#FFFFFF" /&gt;
              &lt;corners android:radius="3dp" /&gt;
              &lt;padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
  &lt;/selector&gt;
  </code></pre>