Я использую два макета с фрагментами, один для портретного режима и один для ландшафтного. Мне нужно добавить липкий нижний колонтитул к обоим макетам, и я успешно добавил его в портретный макет, но когда я использую аналогичный код для альбомного макета, он не работает. Если я устанавливаю layout_width
фрагментов на 0dp
, я не вижу ни одного фрагмента, если я устанавливаю layout_width
на wrap_content
или fill_parent
, фрагменты перекрывают друг друга.
Это то, что у меня есть до сих пор:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>
<!-- Footer -->
<TextView
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
<!-- Footer -->
<fragment android:name="com.app.listing1"
android:id="@+id/fragment1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="@id/footer"
/>
<fragment android:name="com.app.listing2"
android:id="@+id/fragment2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="@id/footer"
/>
</RelativeLayout>
РЕДАКТИРОВАТЬ
Я стал немного ближе к тому, что хочу. Если я поставлю заданную ширину фрагменту1, то получу то, что ищу, но это, очевидно, не идеально. По какой-то причине установка layout_width="wrap_content" для макета обоих фрагментов, а также макетов внутри каждого фрагмента приводит к тому, что первый фрагмент занимает весь экран:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>
<!-- Footer -->
<TextView
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
<!-- Footer -->
<fragment android:name="com.app.listing1"
android:id="@+id/fragment1"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:layout_above="@id/footer"
android:layout_toLeftOf="@id/fragment2"
/>
<fragment android:name="com.app.listing2"
android:id="@+id/fragment2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_above="@id/footer"
android:layout_toRightOf="@id/fragment1"
/>
</RelativeLayout>