android - Buttons aren't shown in the LinearLayout -
i want looks (this screenshot graphical layout editor):
so created layout:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:id="@+id/controls" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <button android:id="@+id/clearbutton" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="@string/clearbuttontext" android:layout_weight="1" /> <edittext android:id="@+id/searchtext" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_weight="5" android:hint="@string/defaultsearchtext" > <requestfocus/> </edittext> <button android:id="@+id/addbutton" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="@string/addbuttontext" android:layout_weight="1" /> </linearlayout> <listview android:id="@+id/list_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" /> </linearlayout>
but when ran app on emulator saw:
when clicked on loupe there still no sign of buttons.
i think should use weights width of elements of horizontal layout. means width of elements weight should 0dp
<linearlayout android:id="@+id/controls" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <button android:id="@+id/clearbutton" android:layout_width="0dp" android:layout_weight="0.2" android:layout_height="match_parent" android:text="@string/clearbuttontext" /> <edittext android:id="@+id/searchtext" android:layout_width="0dp" android:layout_weight="0.6" android:layout_height="match_parent" android:hint="@string/defaultsearchtext" > <requestfocus/> </edittext> <button android:id="@+id/addbutton" android:layout_width="0dp" android:layout_weight="0.3" android:layout_height="match_parent" android:text="@string/addbuttontext" /> </linearlayout>
Comments
Post a Comment