J'ai la mise en page de base suivanteAndroid - Centre TextView Horizontalement à LinearLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/title_bar_background">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:padding="10dp"
android:text="HELLO WORLD" />
</LinearLayout>
<LinearLayout>
Il semble que le xml est correct, mais le texte est aligné à gauche. La vue de texte occupe toute la largeur du parent et la vue de texte est définie pour être centrée. Vous ne savez pas quel est le problème ...
essayer android: gravité = « center » pour votre textview – user370305