title: Android GridLayout. Margins between GridLayout cells
body: <p>This is my GridLayout xml code that is inside ConstraintLayout</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#000000"
  tools:context="solutions.elegant.com.procenty.activites.RabatActivity"&gt;
  
   &lt;android.support.v7.widget.GridLayout
       android:layout_height="0dp"
       android:layout_width="0dp"
       android:layout_weight="4"
       app:rowCount="3"
       app:columnCount="4"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintTop_toBottomOf="@id/btn_splaty"
       app:layout_constraintLeft_toLeftOf="parent"
       app:layout_constraintRight_toRightOf="parent"
       android:layout_marginLeft="50dp"
       android:layout_marginRight="50dp"
       android:layout_marginBottom="5dp"
       android:layout_marginTop="5dp"
       app:useDefaultMargins="false"
       app:orientation="horizontal"&gt;
  
       &lt;Button
           style="@style/MyKeyboardButtons"
           android:id="@+id/btn_0"
           android:text="0" /&gt;
       &lt;Button
           style="@style/MyKeyboardButtons"
           android:id="@+id/btn_1"
           android:text="1"
           /&gt;
       &lt;Button
           style="@style/MyKeyboardButtons"
           android:id="@+id/btn_2"
           android:text="2" /&gt;
       &lt;Button
           style="@style/MyKeyboardButtons"
           android:id="@+id/btn_3"
           android:text="3" /&gt;
       &lt;Button
           style="@style/MyKeyboardButtons"
           android:id="@+id/btn_4"
           android:text="4" /&gt;
       &lt;Button
          style="@style/MyKeyboardButtons"
          android:id="@+id/btn_5"
          android:text="5" /&gt;
       &lt;Button
          style="@style/MyKeyboardButtons"
          android:id="@+id/btn_6"
          android:text="6" /&gt;
       &lt;Button
          style="@style/MyKeyboardButtons"
          android:id="@+id/btn_7"
          android:text="7" /&gt;
       &lt;Button
          style="@style/MyKeyboardButtons"
          android:id="@+id/btn_8"
          android:text="8" /&gt;
       &lt;Button
          style="@style/MyKeyboardButtons"
          android:id="@+id/btn_9"
          android:text="9" /&gt;
       &lt;Button
          style="@style/MyKeyboardButtons"
          android:id="@+id/btn_kropka"
          android:text="." /&gt;
       &lt;Button
          style="@style/MyKeyboardButtons"
          android:id="@+id/btn_remove"
          android:text="l" /&gt;
   &lt;/android.support.v7.widget.GridLayout&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>And this is code for button style:</p>
  
  <pre><code>&lt;style name="MyKeyboardButtons"&gt;
      &lt;item name="android:layout_width"&gt;0dp&lt;/item&gt;
      &lt;item name="android:layout_height"&gt;0dp&lt;/item&gt;
      &lt;item name="android:textSize"&gt;25sp&lt;/item&gt;
      &lt;item name="android:textColor"&gt;#ffffff&lt;/item&gt;
      &lt;item name="android:background"&gt;#151515&lt;/item&gt;
      &lt;item name="layout_columnWeight"&gt;1&lt;/item&gt;
      &lt;item name="layout_rowWeight"&gt;1&lt;/item&gt;
      &lt;item name="android:onClick"&gt;modifyET&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>And this is the visible result:</p>
  
  <p><a href="https://i.stack.imgur.com/MYlBE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MYlBE.png" alt="enter image description here"></a></p>
  
  <p>Now i don't like the fact that there is no space between the buttons so first I add to the button style line:</p>
  
  <pre><code> &lt;item name="android:layout_marginRight"&gt;2dp&lt;/item&gt;
  </code></pre>
  
  <p>The result is:</p>
  
  <p><a href="https://i.stack.imgur.com/OVQE2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OVQE2.png" alt="enter image description here"></a></p>
  
  <p>I added a margin between gridLayout columns.Now I want to add margin between rows so I again add a line to the button style:</p>
  
  <pre><code>&lt;item name="android:layout_marginBottom"&gt;2dp&lt;/item&gt;
  </code></pre>
  
  <p>And the result is not what I expected :</p>
  
  <p><a href="https://i.stack.imgur.com/O8XOx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O8XOx.png" alt="enter image description here"></a></p>
  
  <p>The question is what is wrong here? How can I fix this so I have margins in both
  dimensions between the buttons?</p>