7
我很奇怪,爲什麼出現這種情況:的Android的LinearLayout填充寬度
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:gravity="center_vertical"
android:layout_height="wrap_content" android:layout_gravity="top"
android:background="@drawable/gradient" android:focusable="true"
android:paddingTop="5dip" android:paddingBottom="5dip"
android:focusableInTouchMode="true">
<EditText android:id="@+id/searchField"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:paddingTop="2dip" android:paddingBottom="2dip"
android:paddingLeft="10dip" android:paddingRight="10dip"
android:inputType="textVisiblePassword" android:radius="5dip"
android:layout_marginLeft="10dip"
android:background="@drawable/search_background" android:textColor="#000000" />
<Button android:id="@+id/info" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:background="@drawable/info_btn" />
</LinearLayout>
如果我設置「FILL_PARENT」我的EditText的layout_width,需要家長的整個寬度和按鍵消失(我想這是隱藏在EditText下面)。
有人可以解釋我嗎?我想讓Button獲取自己的寬度,EditText獲取剩餘的寬度。
非常感謝!缺少的屬性「layout_weight」+「0dip」寬度解決了所有問題。 – obo 2011-06-03 21:08:37
也感謝我。 – 2012-01-31 13:11:03