2010-06-02 73 views
8

我遵循描述here的方法來創建EditText輸入活動。但是這個視圖並不能滿足屏幕的寬度。我怎麼知道適合屏幕寬度?如何將對話主題活動寬度設置爲屏幕寬度?

alt text http://img405.imageshack.us/img405/5057/activitythemed.png

<activity android:name="TextEntryActivity" 
      android:label="My Activity" 
      android:theme="@android:style/Theme.Dialog"/> 

-

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:orientation="vertical" 
    android:gravity="right" 
    android:layout_height="wrap_content"> 
    <EditText 
     android:text="@+id/txtValue" 
     android:id="@+id/txtValue" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"></EditText> 
    <Button 
     android:text="Done" 
     android:id="@+id/btnDone" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"></Button> 
</LinearLayout> 
+1

我懷疑它是否重複。這個問題是關於Dialog主題活動,它與對話框不同。 – jimmy0251 2014-11-05 19:30:31

回答

1

設置android:minWidth和/或在您的LinearLayout android:minHeight

+0

設置爲什麼?... – Pentium10 2010-06-02 21:51:18

+0

以「fill_parent」,與android:layout_width – AaronM 2010-06-02 21:52:32

+0

相同的方式,這是行不通的。錯誤:錯誤:字符串類型不允許('minWidth'值'fill_parent')。 – Pentium10 2010-06-02 21:56:19

0

簡短的回答是,你不能。對話只是爲了包裝它的內容。如果你想內容填滿屏幕,你應該使用一個活動

1

另一種選擇是使用AlertDialog,而不是對話框。

+0

非常感謝! – susemi99 2016-10-18 04:40:31

相關問題