Home > DeveloperSection > Forums > How do I center text horizontally and vertically in a TextView in Android?
ezra heywood
ezra heywood

Total Post:145

Points:1019
Posted on    May-19-2015 1:08 AM

 Android Android 
Ratings:


 1 Reply(s)
 465  View(s)
Rate this:
How do I center the text horizontally and vertically in a TextView in Android, so that it appears exactly in the middle of the TextView


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Posted on    May-19-2015 6:44 AM

Use:
android:gravity="center" 
in your TextView  tags xml
The textview has to be match_parent or fill_parent for this to work. If its wrap content, then it will not center.

Don't want to miss updates? Please click the below button!

Follow MindStick