我得到這個:我在做什麼重量有問題?
但是我有這樣的佈局代碼:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/editText_search"
android:layout_width="fill_parent"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:text="" />
<Button android:id="@+id/button_search"
android:layout_width="fill_parent"
android:layout_weight="0.3"
android:layout_height="wrap_content"
android:text="@string/search"
/>
</LinearLayout>
所以,你可以看到,我希望按鈕爲30%,而到的EditText 70%
兩個問題:
- 我是什麼做錯了嗎?
- 我應該使用重量嗎?因爲在平板電腦30%的可能是太多的按鈕(也許我應該爲按鈕使用絕對值)
是這個完整的XML,你對的LinearLayout的父母任何空白,爲平板電腦保持一個不同的XML文件,根據屏幕大小 – 2014-09-01 00:37:46
添加weightSum =「1.0」至你的LinearLayout和子級應該有layout_width =「0dp」來保證。 – 2014-09-01 00:39:55
不是不完整的XML ...這裏顯示的線性佈局(水平)是另一個線性佈局(垂直)的子節點 – sports 2014-09-01 00:40:33