I'd like to place the TextView in the middle horizontally...

Asked 1 years ago, Updated 1 years ago, 112 views

I want to print out a text view in the middle of the screen, what should I do??

android text center textview

2022-09-21 20:56

1 Answers

In XML layout,

    <TextView  
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:gravity="center"
        android:text="@string/**yourtextstring**"
    />

You can do it like this. In Java (textView object name).setGravity(Gravity.CENTER: This is how you do it.


2022-09-21 20:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.