views:

11326

answers:

4

How do I center text horizontally and vertical in a TextView in Android? So that it appears exactly in the middle of the screen.

+27  A: 

I'm assuming you're using XML layout.

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="center_vertical|center_horizontal"
    android:text="@string/**yourtextstring**"
/>
Bill
A: 

hi how to move image dynamically in android

Refer me an option

Thnks in advance

Hello Sudhindra,That is how you answer a question. To ask your own question click the "Ask Question" button.
J. Pablo Fernández
+7  A: 

You can also set it up dynamically using:

textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
zeevb
+4  A: 

android:gravity="center" will do the trick

Jean