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