Используйте RelativeLayout
для размещения верхних и нижних фрагментов, а затем между ними добавьте горизонтальный LinearLayout
, содержащий фрагмент списка и последний динамический фрагмент. Размеры фрагментов можно поместить в файл dimens
, у меня есть hardcoded 48
dp в xml; также область списка занимает 20% от ширины, а область содержимого занимает остальное. Вот кое-что, чтобы вы начали:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/top_fragment"
android:name="com.adip.sampler.fragments.TopFragment"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentTop="true" />
<fragment
android:id="@+id/bottom_fragment"
android:name="com.adip.sampler.fragments.BottomFragment"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_fragment"
android:layout_below="@+id/top_fragment"
android:baselineAligned="false"
android:orientation="horizontal" >
<fragment
android:id="@+id/list_fragment"
name="com.adip.sampler.fragments.ListFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/dynamic_area"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" >
</FrameLayout>
</LinearLayout>
</RelativeLayout>
или если вы хотите иметь только viewgroups и не fragment
теги Вы не могли бы иметь этот макет (Вы можете использовать любой ViewGroup
вместо FrameLayout
, я использую его по соображениям эффективности) :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/top_fragment"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentTop="true" />
<FrameLayout
android:id="@+id/bottom_fragment"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_fragment"
android:layout_below="@+id/top_fragment"
android:baselineAligned="false"
android:orientation="horizontal" >
<FrameLayout
android:id="@+id/list_fragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/dynamic_area"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" >
</FrameLayout>
</LinearLayout>
</RelativeLayout>
что, если я хотел сделать то же самое, но динамически через борт не фрагментов в XML ... – sirvon
не могли бы вы объяснить, что вы имеете в виду 'динамически через борт не фрагментов в xml'? – gunar
все фрагменты, созданные в коде, ни один не создан в xml – sirvon