title: Android TextView text won't center
body: <p>I am trying to make a PIN entry activity, but one little thing is not quite working for me. I can't get the text to center in the TextView's at the top of the screenshot here:</p>
  
  <p><img src="https://i.stack.imgur.com/MEouI.png" alt="Pin Screenshot"></p>
  
  <p>The way it will work is when the user is entering a PIN, I will place a star in each TextView for visible feedback. The problem is, I want the star to be centered. I have tried layout_gravity="center", but it doesn't make a difference. Here's my current layout:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"&gt;
       &lt;TextView 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:layout_height="wrap_content" 
       android:id="@+id/textView1" 
       android:text="PIN Required" 
       android:layout_width="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:layout_marginBottom="12sp"
       &gt;&lt;/TextView&gt;
       &lt;LinearLayout 
       android:layout_width="match_parent" 
       android:id="@+id/linearLayout1" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="12sp" 
       android:layout_gravity="center_horizontal"
       &gt;
           &lt;TextView 
         android:id="@+id/text1" 
         android:layout_height="32sp" 
         android:layout_width="48sp" 
         android:layout_weight="1" 
         android:layout_marginRight="2sp" 
         android:layout_marginLeft="48sp" 
         android:background="#FFFFFF" 
         android:text="X" 
         android:layout_gravity="center"
         &gt;&lt;/TextView&gt;
           &lt;TextView 
         android:id="@+id/text2" 
         android:layout_height="32sp" 
         android:layout_width="48sp" 
         android:layout_weight="1" 
         android:layout_marginRight="2sp" 
         android:layout_marginLeft="2sp" 
         android:background="#FFFFFF"
         &gt;&lt;/TextView&gt;
           &lt;TextView 
         android:id="@+id/text3" 
         android:layout_height="32sp" 
         android:layout_width="48sp" 
         android:layout_weight="1" 
         android:layout_marginRight="2sp" 
         android:layout_marginLeft="2sp" 
         android:background="#FFFFFF"
         &gt;&lt;/TextView&gt;
           &lt;TextView 
         android:id="@+id/text4" 
         android:layout_height="32sp" 
         android:layout_width="48sp" 
         android:layout_weight="1" 
         android:layout_marginRight="48sp" 
         android:layout_marginLeft="2sp" 
         android:background="#FFFFFF"
         &gt;&lt;/TextView&gt;
       &lt;/LinearLayout&gt;
       &lt;LinearLayout 
       android:layout_width="match_parent" 
       android:id="@+id/linearLayout2" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="12sp"
       &gt;
           &lt;Button 
         android:text="1" 
         android:textColor="#FFFFFF" 
         android:id="@+id/button1" 
         android:layout_height="32sp" 
         android:layout_width="64sp" 
         android:layout_weight="1" 
         android:editable="false" 
         android:layout_marginRight="2sp" 
         android:layout_marginLeft="48sp" 
         android:background="@drawable/action_background_gradient" 
         android:onClick="ButtonClicked"
         &gt;&lt;/Button&gt;
           &lt;Button 
         android:text="2" 
         android:textColor="#FFFFFF" 
         android:id="@+id/button2" 
         android:layout_height="32sp" 
         android:layout_width="64sp" 
         android:layout_weight="1" 
         android:editable="false" 
         android:layout_marginRight="2sp" 
         android:layout_marginLeft="2sp" 
         android:background="@drawable/action_background_gradient" 
         android:onClick="ButtonClicked"
         &gt;&lt;/Button&gt;
           &lt;Button 
         android:text="3" 
         android:textColor="#FFFFFF" 
         android:id="@+id/button3" 
         android:layout_height="32sp" 
         android:layout_width="64sp" 
         android:layout_weight="1" 
         android:editable="false" 
         android:layout_marginRight="48sp" 
         android:layout_marginLeft="2sp" 
         android:background="@drawable/action_background_gradient" 
         android:onClick="ButtonClicked"
         &gt;&lt;/Button&gt;
       &lt;/LinearLayout&gt;
  
       &lt;!--... and so on for the rest of the buttons ... --&gt;
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I've got that android:text="X" in there for the first textview just so I can see if it is working. When I am done tweaking the layout, that will go away.
  What simple thing am I missing?</p>