title: Android SDK: RelativeLayout - Button WILL NOT center horizontally, even with Layout_CenterHorizontal=true
body: <p>I really hope somebody can help me here because I am going to start pulling my hair out if this keeps doing what it's doing.</p>
  
  <p>I'm trying to design a layout and I want all of my stuff to be centered. So far, everything is. However, the Save button I created will not center itself for the life of it. It consistently aligns its left edge with the center of the screen, rather than the center of the button itself.</p>
  
  <p>Below is a screenshot of my simple design and the xml behind it...  Any help will be GREATLY appreciated!</p>
  
  <p><a href="https://i.stack.imgur.com/IrPhI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IrPhI.jpg" alt="enter image description here"></a></p>
  
  
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:showIn="@layout/activity_settings"
      tools:context="com.hypertom.weeklymealgenerator.SettingsActivity"
      android:gravity="center_horizontal"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:text="@string/strSettingsTitle"
          android:id="@+id/textView"
          android:textIsSelectable="false"
          android:textSize="30sp"
          android:layout_alignParentTop="true"
          android:layout_alignStart="@+id/textView2" /&gt;
  
      &lt;TextView
          android:layout_width="150dp"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:text="@string/strSettingsNumMeals"
          android:id="@+id/textView2"
          android:layout_below="@+id/textView"
          android:layout_alignParentStart="true"
          android:layout_marginTop="40dp"
          android:layout_marginLeft="10dp"
          android:gravity="right"
          android:textSize="18sp" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:text="@string/strSettingsThresholdMin"
          android:id="@+id/textView3"
          android:layout_below="@+id/textView2"
          android:layout_alignEnd="@+id/textView2"
          android:layout_marginTop="10dp"
          android:gravity="right"
          android:textSize="18sp" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:text="@string/strSettingsThresholdMax"
          android:id="@+id/textView4"
          android:layout_below="@+id/textView3"
          android:layout_alignEnd="@+id/textView3"
          android:layout_marginTop="10dp"
          android:gravity="right"
          android:textSize="18sp" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:text="@string/strSettingsNumServings"
          android:id="@+id/textView5"
          android:layout_below="@+id/textView4"
          android:layout_alignEnd="@+id/textView4"
          android:layout_marginTop="10dp"
          android:gravity="right"
          android:textSize="18sp" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:text="@string/strSettingsNumSubstitutes"
          android:id="@+id/textView6"
          android:layout_below="@+id/textView5"
          android:layout_alignEnd="@+id/textView5"
          android:layout_marginTop="10dp"
          android:gravity="right"
          android:textSize="18sp" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/btnSettingsSave"
          android:id="@+id/button4"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="200dp" /&gt;
  
      &lt;EditText
          android:layout_width="65dp"
          android:layout_height="wrap_content"
          android:inputType="number"
          android:ems="10"
          android:id="@+id/editText"
          android:layout_alignBottom="@+id/textView2"
          android:layout_toEndOf="@+id/textView2"
          android:layout_marginBottom="-12dp"
          android:textSize="18sp"
          android:gravity="center" /&gt;
  
      &lt;EditText
          android:layout_width="65dp"
          android:layout_height="wrap_content"
          android:inputType="number"
          android:ems="10"
          android:id="@+id/editText2"
          android:layout_alignBottom="@+id/textView3"
          android:layout_alignStart="@+id/editText"
          android:textSize="18sp"
          android:layout_marginBottom="-12dp"
          android:gravity="center" /&gt;
  
      &lt;EditText
          android:layout_width="65dp"
          android:layout_height="wrap_content"
          android:inputType="number"
          android:ems="10"
          android:id="@+id/editText3"
          android:layout_above="@+id/textView5"
          android:layout_alignStart="@+id/editText2"
          android:layout_marginBottom="-12dp"
          android:textSize="18sp"
          android:gravity="center" /&gt;
  
      &lt;EditText
          android:layout_width="65dp"
          android:layout_height="wrap_content"
          android:inputType="number"
          android:ems="10"
          android:id="@+id/editText4"
          android:layout_above="@+id/textView6"
          android:layout_alignStart="@+id/editText3"
          android:textSize="18sp"
          android:layout_marginBottom="-12dp"
          android:gravity="center" /&gt;
  
      &lt;EditText
          android:layout_width="65dp"
          android:layout_height="wrap_content"
          android:inputType="number"
          android:ems="10"
          android:id="@+id/editText5"
          android:layout_alignBottom="@+id/textView6"
          android:layout_alignStart="@+id/editText4"
          android:layout_marginBottom="-12dp"
          android:textSize="18sp"
          android:gravity="center" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>