たぶん私はlayout_weightパラメーターを誤解しましたが、なぜこのようなものが機能しないのか理解できません...
<?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" android:weightSum="1">
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView" android:layout_weight="0.3" android:background="@color/apr_blue"/>
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="TextView"
android:background="@color/apr_brightyellow"/>
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="TextView"
android:background="@color/apr_yellow"/>
</LinearLayout>
LinearLayout内に3つ以上のテキストビューがあります。パーセンテージ幅の列に配置したいと思います。そしてそれはそれが生み出すものです:
layout_weightを0.3/0.2/0.5に設定した場合
次に、layout_weightパラメーターを次のように少し変更しました。
<?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" android:weightSum="1">
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView" android:layout_weight="0.3" android:background="@color/apr_blue"/>
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="TextView"
android:background="@color/apr_brightyellow"/>
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:text="TextView"
android:background="@color/apr_yellow"/>
</LinearLayout>
そして今、私は私が望むようにそれを手に入れます:
layout_weightを0.3/0.2/0.5に設定した場合
それはバグなのか、それともlayout_weightの全体を本当に誤解しているのでしょうか。