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?
How do I center text horizontally and vertically in a TextView on Android
De openkb
Sommaire |
Questions
Answers
I m assuming you re using XML layout.
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/**yourtextstring**"
/>
and as @stealthcopter commented in java: .setGravity(Gravity.CENTER);
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/432037/how-do-i-center-text-horizontally-and-vertically-in-a-textview-on-android