I have a little problem defining relative layout. I have a scroll list view and two buttons that are always visible at the bottom of the list. I just wish my button had 50% width filling the line. This is my code:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/testbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Save" /> <Button android:id="@+id/cancelButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_toRightOf="@+id/testbutton" android:text="Cancel"/> <ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/LstPeriodOptions" android:layout_alignParentTop="true" android:layout_above="@id/testbutton" /> </RelativeLayout>
I tried to enter buttons in a linear layout and give a gravity value = 1 with a width = 0dp, but in this case the ListView will disappear. could you help me?
Sorry for my English. This is the result I would like to have:

Thanks a lot, best regards.
EDIT: This is what I tried with linear layout:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/container" > <Button android:id="@+id/testbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Guardar" /> <Button android:id="@+id/cancelButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_toRightOf="@+id/testbutton" android:text="Cancelar"/> </LinearLayout> <ListView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/LstPeriodOptions" android:layout_alignParentTop="true" android:layout_above="@id/container" /> </RelativeLayout>
android layout relativelayout
puro_nervio
source share