0
我研究了另一個線程上的屬性值wrap_content,發現它的功能是「強制[視圖]展開得足夠遠以包含它包含的值(或子控件)。對於控件 - 比如文本框)或圖像(ImageView的) - 這將包裝被顯示的文本或圖像「(What's the difference between fill_parent and wrap_content?) 赫雷什我的代碼(用於空的EditText爲什麼具有空文本的edittext仍然有一些高度?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Email"
android:padding="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
並將所得佈局(選擇的一個是編輯文本)http://imgur.com/6H8caKT
我的問題是,因爲編輯文本不包含任何內容(空文本),不應該wrap_內容強制它沒有高度?
用戶需要能夠鍵入伸展。如果「EditText」沒有高度,他們不能。因此,我會假設'EditText'強制執行最小單行高度。 – CommonsWare
如果你想隱藏一個元素看看這篇文章http://stackoverflow.com/questions/4480489/can-you-hide-an-element-in-a-layout-such-as-a-spinner-取決於活動 –
不,我不想隱藏它。林只是好奇,爲什麼事情仍然有高度後wrap_content – committedandroider