【发布时间】:2013-10-27 12:36:51
【问题描述】:
我正在为大屏幕构建一个布局,它应该由 2 个不同的部分组成,一个左侧和一个右侧。为此,我认为使用 2 Fragments 是正确的选择。
然后我看了一下使用 Master/Detail-Flow 的导航示例。它有一个 2 窗格布局,右侧是导航,左侧是详细视图。
但在该示例中,与我预期看到的不同,对于详细视图,有一个 FrameLayout,然后包含一个 Fragment,而不是直接保存一个 Fragment。
布局 XML 如下所示(示例):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:baselineAligned="false"
android:divider="?android:attr/dividerHorizontal"
android:orientation="horizontal"
android:showDividers="middle"
tools:context=".WorkStationListActivity" >
<fragment
android:id="@+id/workstation_list"
android:name="de.tuhh.ipmt.ialp.history.WorkStationListFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
tools:layout="@android:layout/list_content" />
<FrameLayout
android:id="@+id/workstation_detail_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3" />
</LinearLayout>
我现在的问题是:为什么在详细视图中使用FrameLayout 而不是Fragment 本身?原因或优势是什么?我也应该使用它吗?
【问题讨论】:
标签: android android-fragments android-framelayout