title: How to horizontally center a button in a RelativeLayout?
body: <p>Having searched for a solution first (for example <a href="https://stackoverflow.com/questions/9124075/textview-horizontal-center-in-relativelayout">here</a>) I came upon the following solution:</p>
  
  <pre><code>android:layout_centerHorizontal="true"
  </code></pre>
  
  <p>which does not work for me (see third button). Below is the full example code of three buttons in a <code>RelativeLayout</code>, in which the middle button should be centered (horizontally and vertically, which the button is), and the two other buttons are supposed to be symmetrical placed on the screen, horizontally centered. However, they are not, using the suggested solution I found many times. </p>
  
  <p>So what do I miss?</p>
  
  <p>Full code:</p>
  
  <pre><code>&lt;LinearLayout 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:id="@+id/checkscreen"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.impyiablue.checkpoint.CheckScreen"&gt;
  
      &lt;RelativeLayout
          android:id="@+id/content"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_marginTop="20dp"
          android:layout_weight="1"
          android:orientation="vertical"&gt;
  
  
          &lt;Button
              android:id="@+id/check_cancel"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/check_next"
              android:textSize="20sp"
              android:padding="25dip"
              android:layout_alignParentTop="true"
              android:layout_alignLeft="@+id/check_now"
              android:layout_alignStart="@+id/check_now"
              android:layout_marginTop="50dp" /&gt;
  
          &lt;Button
              android:id="@+id/check_now"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerInParent="true"
              android:text="@string/check_now"
              android:padding="70dip"
              android:textSize="20sp" /&gt;
  
          &lt;Button
              android:id="@+id/check_redo"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:text="@string/check_redo"
              android:textSize="20sp"
              android:padding="25dip"
              android:layout_alignParentBottom="true"
              android:layout_alignLeft="@+id/check_now"
              android:layout_alignStart="@+id/check_now"
              android:layout_marginBottom="50dp" /&gt;
  
      &lt;/RelativeLayout&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/fvIan.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fvIan.png" alt="Screenshot"></a></p>