title: Android Text Alignment - Pixel Perfect
body: <p>In the screenshot below, I am attempting to get the text in the blue box to be aligned in the centre. It is to low down and needs to be lifted a pixel or two. I have been playing with the padding but it does not seem to have any effect.</p>
  
  <p><img src="https://i.stack.imgur.com/aVF8o.png" alt="enter image description here"></p>
  
  <p>The layout XML is here :</p>
  
  <pre><code>&lt;RelativeLayout  xmlns:tools="http://schemas.android.com/tools"
  android:orientation="horizontal"
  android:layout_width="match_parent" 
  android:layout_height="match_parent" 
  android:layout_marginRight="5dp"
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
          &lt;TextView android:id="@+id/tvName" 
          android:layout_width="60dp" 
          android:layout_height="20dp" 
          android:layout_marginLeft="10dp" 
          android:layout_marginRight="10dp" 
          android:layout_marginTop="3dp" 
          android:background="@drawable/rectanglesegment" 
          android:gravity="center"
          android:paddingBottom="2dp" 
          android:text="XXX" android:textSize="16sp" 
          android:textAppearance="?android:attr/textAppearanceMedium"/&gt;
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>After feedback from @Snicolas I now have the following :</p>
  
  <p><img src="https://i.stack.imgur.com/XKmY0.png" alt="enter image description here"></p>
  
  <p>With this layout </p>
  
  <pre><code>&lt;TextView android:id="@+id/tvName" 
  android:layout_width="60dp" 
  android:layout_height="fill_parent" 
  android:layout_marginLeft="10dp" 
  android:layout_marginRight="10dp" 
  android:layout_marginTop="2dp"
  android:layout_marginBottom="2dp"
  android:background="@drawable/rectanglesegment" 
  android:gravity="center"
  android:text="abv" android:textSize="16sp" 
  android:textAppearance="?android:attr/textAppearanceMedium"/&gt;
  </code></pre>