(私が思うに)単純な LinearLayout に問題があります。(長い質問 - 申し訳ありません) 次のような RelativeLayout を使用した XML レイアウトがあります。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/display_Player_Init"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Player" />
<TextView
android:id="@+id/display_USGA_Index"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:gravity="right"
android:layout_toRightOf="@+id/display_Tees"
android:text="IDX" />
<TextView
android:id="@+id/display_Course_HCP"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:gravity="right"
android:layout_toRightOf="@+id/display_USGA_Index"
android:text="HCP" />
<TextView
android:id="@+id/display_Course"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/display_Player_Init"
android:text="Course" />
<TextView
android:id="@+id/display_Tees"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/display_Course"
android:text="Tees" />
</RelativeLayout>
これは、次のように IDE プレビューに正しく表示されます。
くそ、画像を投稿するのに十分な担当者ポイントがありません。
アプリはこれを正しく表示します (5 つの値の順序に注意してください)。
画像を投稿するのに十分な担当者ポイントがありません。
RelativeLayout は大きすぎるように見えたので、次のように単純な LinearLayout を使用したかっただけです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<TextView
android:id="@+id/display_Player_Init"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="Player" />
<TextView
android:id="@+id/display_USGA_Index"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="right"
android:text="IDX" />
<TextView
android:id="@+id/display_Course_HCP"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="right"
android:text="HCP" />
<TextView
android:id="@+id/display_Course"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Course" />
<TextView
android:id="@+id/display_Tees"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Tees" />
</LinearLayout>
次のようにIDEで正しくプレビューされました(フィールドは最初のレイアウトから順番がずれていることに注意してください。修正しようとしています):
画像を投稿するのに十分な担当者ポイントがありません。
そして、次のようにアプリで適切にレンダリングします。
画像を投稿するのに十分な担当者ポイントがありません。
ここで、LinearLayout XML で TextViews の順序を変更すると、フィールドに間違った値が表示されているかのようにレンダリングされます。XML は次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<TextView
android:id="@+id/display_Player_Init"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="Player" />
<TextView
android:id="@+id/display_Course"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Course" />
<TextView
android:id="@+id/display_Tees"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="Tees" />
<TextView
android:id="@+id/display_USGA_Index"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="right"
android:text="IDX" />
<TextView
android:id="@+id/display_Course_HCP"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="right"
android:text="HCP" />
</LinearLayout>
(正しい)IDE プレビューは次のとおり です。画像を投稿するのに十分な担当者ポイントがありません。
ただし、アプリのレンダリングは次のとおりです。
画像を投稿するのに十分な担当者ポイントがありません。 文字列「ABC CC」を右の列に配置し、その文字列を HCP フィールドに配置しているかのようにラップします。
フィールドの順序は正しいですが、値が何らかの理由で入れ替わっていることに注意してください。XML フィールドは適切な順序でレンダリングされますが、フィールドの値は、Name、Index、Tees、HCP、Course で、「course」の値は HCP フィールドの幅に合わせられます。
これらの例の間でコードが変更されていないため、xml が問題を引き起こしているようです。誰かが理由を理解するのを手伝ってくれますか? (画像がなくてすみません。)
ありがとう。