我正在使用android:theme =「@ android:style/Theme.Dialog」的活動使其充當對話框。最接近於原生對話框的行爲:對話框應該填滿屏幕(寬度)還是不對?而且,如果它動態增長,例如,通過輸入填充文本框?Android:對話框的寬度應該是多少?
我的預感是對話框不應該填滿屏幕。我試圖得到這種行爲,但無論我做什麼,在Android 2.2上,對話框寬度似乎填充父項。
我的佈局XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:autoText="true"
android:text="@string/item_delete_dialog_label"
android:padding="5dip" />
<LinearLayout android:layout_height="wrap_content"
android:orientation="horizontal"
style="@android:style/ButtonBar" android:layout_width="fill_parent">
<Button android:id="@+id/yes" android:layout_height="wrap_content"
android:text="@string/button_yes"
android:layout_width="wrap_content"
android:layout_weight="1"/>
<Button android:id="@+id/no" android:layout_height="wrap_content"
android:text="@string/button_no"
android:layout_width="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
我發現關於做一個對話框填滿屏幕寬度的許多問題,但沒有關於使其在寬度換行。我怎樣才能得到這個?