How to Center Android TextView Text Horizontally and Vertically
https://www.viralandroid.com/2015/12/how-can-i-center-textview-text-horizontally-and-vertically.html
In this simple tip, I am going to show how to align android textview text at the center of screen (horizontally and vertically) using XML attribute and programmatically (using java code). You can also center a view or views content i.e. textview or button vertically and horizontally.
To make all these using XML, you have to use layout_gravity attribute. You can also do same thing programmatically (using java code).
Related:
Android Auto Complete using AutoCompleteTextView and MultiAutoCompleteTextView
How to Make Scrollable TextView in Android
How to Make Android TextView Text Selectable
Following are the example of align center android textview text using XML and java code.
res/layout/ android_textview_text_center.xml
src/TextViewTextCenter.java
Output:
To make all these using XML, you have to use layout_gravity attribute. You can also do same thing programmatically (using java code).
Related:
Android Auto Complete using AutoCompleteTextView and MultiAutoCompleteTextView
How to Make Scrollable TextView in Android
How to Make Android TextView Text Selectable
How to Align Android TextView Text Center Horizontally and Vertically
Following are the example of align center android textview text using XML and java code.
Align Android TextView Text Center Using XML
res/layout/ android_textview_text_center.xml
Align Android TextView Text Center Programmatically (Using Java Code)
src/TextViewTextCenter.java
Output: