title: Align button text to top/center horizontal android
body: <p><a href="https://i.stack.imgur.com/eRNxG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eRNxG.png" alt="enter image description here"></a></p>
  
  <p>Hi, I have a button which looks like <code>img1</code>.</p>
  
  <p>I need the button's text to be top/horizonal center like <code>img2</code>.</p>
  
  <p>I tried using this</p>
  
  <pre><code>&lt;Button
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:id="@+id/equalBtn2"
                  android:background="@drawable/blue_payment_button"
                  android:textSize="40sp"
                  android:textColor="@drawable/text_general"
                  android:layout_alignParentTop="true"
                  android:layout_toRightOf="@+id/button15"
                  android:layout_toEndOf="@+id/button15"
                  android:layout_weight="1"
                  android:layout_marginLeft="2dp"
                  android:layout_marginRight="2dp"
                  android:layout_marginBottom="2dp"
                  android:text="0"
                  android:gravity="center_horizontal|top" /&gt;
  </code></pre>
  
  <p>But I get the result as <code>img3</code>.
  I dont want the top spacing between the text and the button's head.
  Please help.
  Thanks in advance.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Button's parent XML</p>
  
  <pre><code> &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="fill_parent"
              android:layout_alignParentLeft="true"
              android:layout_alignParentStart="false"
              android:id="@+id/linearLayout5"
              android:layout_above="@+id/linearLayout3"
              android:layout_weight="1" &gt;
  
              &lt;Button
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:text="C"
                  android:id="@+id/button13"
                  android:layout_alignParentTop="true"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:background="@drawable/blue_payment_button"
                  android:textSize="40sp"
                  android:textColor="@drawable/text_general"
                  android:layout_weight="1"
                  android:layout_margin="2dp" /&gt;
  
              &lt;Button
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:text="0"
                  android:id="@+id/button14"
                  android:background="@drawable/yellow_general_button"
                  android:textSize="40sp"
                  android:textColor="@drawable/text_general"
                  android:layout_alignParentTop="true"
                  android:layout_toRightOf="@+id/button13"
                  android:layout_toEndOf="@+id/button13"
                  android:layout_weight="1"
                  android:layout_margin="2dp" /&gt;
  
              &lt;Button
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:text="&amp;lt;"
                  android:id="@+id/button15"
                  android:background="@drawable/blue_payment_button"
                  android:textSize="40sp"
                  android:textColor="@drawable/text_general"
                  android:layout_alignParentTop="true"
                  android:layout_toRightOf="@+id/button14"
                  android:layout_toEndOf="@+id/button14"
                  android:layout_weight="1"
                  android:layout_margin="2dp" /&gt;
  
              &lt;Button
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:id="@+id/equalBtn2"
                  android:background="@drawable/blue_payment_button"
                  android:textSize="40sp"
                  android:textColor="@drawable/text_general"
                  android:layout_alignParentTop="true"
                  android:layout_toRightOf="@+id/button15"
                  android:layout_toEndOf="@+id/button15"
                  android:layout_weight="1"
                  android:layout_marginLeft="2dp"
                  android:layout_marginRight="2dp"
                  android:layout_marginBottom="2dp"
                  android:text="0"
                  android:gravity="center_horizontal|top" /&gt;
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>