title: How to add a bottom margin to a parent bottom aligned button inside a relative layout?
body: <p>I am using the android studio to create an app currently but I am having issues placing a button in the bottom right of the screen. I opted to populate a relative layout with a few components and the <code>android:layout_marginRight=&quot;&lt;x&gt;dp&quot;</code> has worked so far in enabling me to stop the views from touching the edges. An example of where I used it successfully looks like this (XML for a button that hovers in the top right):</p>
  <pre><code>&lt;RelativeLayout blah&gt;
      &lt;com.google.android.material.button.MaterialButton
          android:id=&quot;someID&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:align_parentEnd=&quot;true&quot; 
          android:layout_marginEnd=&quot;20dp&quot;
          android:layout_marginTop=&quot;20dp&quot;
          and so on describing the button but no more geometric statements
      /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>However, when I do the same for a button that I add the line <code>android:layout_alignParentBottom</code> and the line <code>android:layout_marginBottom</code> the bottom margin line is not effective and the button is glued to the bottom of the screen - here is the offender:
  <a href="https://i.stack.imgur.com/BK7ZX.png" rel="nofollow noreferrer">XML of a button next to android studio render</a>.</p>
  <p>Please can someone explain why this happens and how to fix it? I am trying to place a button in the bottom right with 20dp to its right and underneath it so it 'hovers' there.</p>
  <p>Here is the rest of my XML as it is currently:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      tools:context=&quot;.MainActivity&quot;&gt;
  
      &lt;com.google.android.material.floatingactionbutton.FloatingActionButton
          android:id=&quot;@+id/btn_add_review&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_alignParentEnd=&quot;true&quot;
          android:layout_alignParentBottom=&quot;true&quot;
          android:layout_marginEnd=&quot;20dp&quot;
          android:layout_marginBottom=&quot;20dp&quot;
          android:paddingBottom=&quot;20dp&quot;
          android:clickable=&quot;true&quot;       
          app:backgroundTint=&quot;@color/themeColorOrange&quot;
          app:srcCompat=&quot;@drawable/ic_baseline_add_24&quot; /&gt;
      
  &lt;/RelativeLayout&gt;
  </code></pre>