私は垂直レイアウトを持っています: 2 つのテキスト フィールドとボタンの水平バー:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff00ff00"
android:orientation="vertical"
android:padding="4dp" >
<EditText
android:id="@+id/et_email"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#ff00ffff"
android:inputType="textEmailAddress" >
</EditText>
<EditText
android:id="@+id/et_comment"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#ff00ffff"
android:inputType="textMultiLine"
android:maxLines="5"
android:minLines="5" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_send"
android:layout_weight="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK" />
<Button
android:id="@+id/btn_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some very long text" />
<Button
android:id="@+id/btn_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>
ボタン バーにサイズ ポリシーを設定したいwrap_content
(このアプリにはさまざまなローカライズがあるため、固定サイズにすることさえできません)。また、テキスト フィールドの幅をボタン ボックスと同じにしたいと考えています。プラットフォーム 17 が選択された状態で上記の xml がデザイナー (Eclipse + ADT) でどのように表示されるか (およびどのように表示されるか) を次に示します。色は簡単にデバッグするためのものです:
Android 4.1 タブレットでは次のように表示されます。
このレイアウトは、ダイアログのカスタム レイアウトとして使用されます。コンテンツとタイトルの設定を除いて、Dialog に対して操作は行われていません。
興味深い事実: Android 3.1 タブレットでは、私が望んでいたとおり (および ADT デザイナーが示したものと同じ) に見えます。しかし、4.1ではありません。
目的のレイアウトを実現するにはどうすればよいですか?