Android - две кнопки в одной строке, занимающие всю ширину
У меня есть небольшая проблема с определением относительного расположения. У меня есть список с прокруткой и две кнопки всегда видны в нижней части списка. Я просто хотел бы, чтобы мои две кнопки имели 50% ширины, заполняя строку. Это мой код:
<?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>
Я попытался ввести кнопки в линейный макет и задать гравитацию = 1 с шириной = 0dp, но в этом случае ListView исчезнет. Не могли бы вы мне помочь, пожалуйста?
Извините за мой английский. Вот результат, который я хотел бы получить:
Большое спасибо, с наилучшими пожеланиями.
РЕДАКТИРОВАТЬ: Это то, что я пытался с линейной версткой:
<?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>