2 つの異なるヘッダーに割り当てられた 3 つの異なる値、つまり、1 つの値を持つ最初のヘッダーと 2 つの値を持つ 2 つ目のヘッダーを表示したい
私のアプローチは、「ヘッダーの線形レイアウト」を 40/60 に分割し、「値の線形レイアウト」を 40/30/30 に分割することです。境界線で始まるテキストを表示しないようにするために、どこにでもandroid:layout_marginLeft="15dp"
in を配置したので、最終的には比例したままになります。
私の XML では、次のように宣言します。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/txt_price_chf"
/>
<TextView
android:layout_weight="6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/txt_price_offshore_chf"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/tv_price_ch"
android:layout_weight="4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="Value1"
/>
<TextView android:id="@+id/tv_price_off_chf"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="Value2"
/>
<TextView android:id="@+id/tv_price_off_eur"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="Value3"
/>
</LinearLayout>
結果は次の出力です。
「Price offshore:」-TextView と「Value2」-TextView が一致しないのはなぜですか? 「オフショアの価格」がstrings.xmlに保存されていることに注意してください。空白などのエラーはありません。最初は が原因かと思いましたandroid:layout_marginLeft="15dp"
が、
「dp」は特定の解像度に対する相対値であることをどのように理解したか(したがって、分割はこれに
android:layout_weigth
影響を与えるべきではありません)余白を削除しても、まだ整列していません。
誰かアイデアはありますか?明らかなことを見落としていますか?