私はこれについて宿題をしていましたが、私が遭遇したすべての提案が機能していないようです. 私はAndroidアプリケーションに不慣れで、答えは簡単かもしれませんが、どこが間違っているのかわかりません....
改行 (\n) のある文字列値を含む TextView フィールドがあります。グラフィック出力では、テキストの下の行が TextView コンテナーの中央に配置されていません。私のコードは次のとおりです。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView5"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dp"
android:text="@string/maxText"
android:textAlignment="gravity"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</RelativeLayout>
私の文字列は次のとおりです。
<string name="maxText">My text part 1:\nMy text part 2</string>
出力されたテキストの下の行はコンテナーの左に配置されますが、中央に配置する必要があります。フォーラムなどで出くわしたすべての提案を試しましたが、役に立ちませんでした。
これについて何か助けていただければ幸いです。