How to keep Textview centralized in the emulator?

Asked

Viewed 93 times

-1

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

inserir a descrição da imagem aqui

1 answer

1

If textView is inside a Linearlayout you can assign it to it like this 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" />
  • 1

    Thank you, I solved it that way

Browser other questions tagged

You are not signed in. Login or sign up in order to post.