How to keep TextView centralized in the emulator?

-1

I am a beginner in development and have learned how to develop for Android with Android Studio 3.1.1. In one of the exercises I'm doing, it is necessary to retrieve which checkbox was checked and display in a textView, in the interface I center the textView and squeeze into the emulator, when I click the button to show the result it is not centered, how can I keep this centered result on the screen?

    
asked by anonymous 26.04.2018 / 15:19

1 answer

1

If the textView is within a LinearLayout you can assign it to it so android: gravity="center" will already center the text.

  <TextView
                    android:id="@+id/txtSeusEquipamentos"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:paddingRight="30dp"
                    android:text="@string/selecionarPool"
                    android:textStyle="bold" />
    
26.04.2018 / 15:23