私はLinearLayout横向きで 2人のTextView子供がいます。私の目標はTextView、テキスト コンテンツに合わせて左を拡張することですが、最大幅までにします (右のスペースを空けるためTextView)。layout_weight重要なのは、指定されている方法と同様のパーセンテージでこの最大幅を表現できるようにしたいということです。
を設定する際の問題layout_weightはTextView、コンテンツが余分なスペースを必要としない場合でも、無条件に最大幅を埋めるために拡張されることです。
これが私の現在のレイアウトです:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/subject"
android:textSize="18sp"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.8"/>
<TextView android:id="@+id/date"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>