Android TextView allows user to display text in android application. In this simple tip, I am going to show how to programmatically align android TextView in the center of the screen. To display text in the center of screen programmatically you have to use .setGravity(Gravity.CENTER) method.

How to Make Scrollable TextView in Android
How to Set Android Button and TextView Border Color
Android Material Design with Design Support Library

Android Example: How to Align Android TextView in the Center of the Screen

XML Layout File

Your XML layout file looks like this.

Java Activity File

And your java activity file code looks like this.

Now, run your application which looks like this.

Programmatically Align Android TextView in the Center of the Screen
Android TextView in the Center

Post a Comment

Powered by Blogger.