0

GitHub の簡単なテスト アプリで、ユーザーのアバターを表示しようとしています。次に、2 つのTextViewUsernameCity (中央揃えにする必要があります)、最後にListFragmentListViewのメインを表示します。

スクリーンショット

レイアウト ファイルfragment_account.xmlandroid:textAlignment="center"で、両方のs (上記のスクリーンショットの赤い矢印でマーク)を設定しようとしTextViewましたが、効果がありません。

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/avatar"
        android:layout_width="96dp"
        android:layout_height="96dp"
        android:layout_gravity="center_horizontal"
        android:src="@drawable/photo"
        app:border_width="2dp"
        app:border_color="#FFF"/>

    <TextView                     <!-- how to center-align? -->
        android:id="@+id/username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAlignment="center"
        android:text="Username"/>

    <TextView                     <!-- how to center-align? -->
        android:id="@+id/city"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAlignment="center"
        android:text="City"/>

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </ListView>

</LinearLayout>

これらのラベルを中央揃えにする良い方法があれば、アドバイスしてください。

4

1 に答える 1