큰 화면을위한 레이아웃을 만들고 있는데, 왼쪽과 오른쪽의 두 가지 파트로 구성되어 있습니다. 그것을하기 위해 나는 2 개의 단편을 사용하는 것이 올바른 선택이라고 생각했습니다.Android : 언제/왜 조각 대신 FrameLayout을 사용해야합니까?
그런 다음 마스터/세부 흐름을 사용하여 탐색 예제를 살펴 보았습니다. 그것은 오른쪽에 네비게이션이 있고 왼쪽에는 상세보기 인 2 칸 레이아웃이 있습니다. 내가 볼 것으로 예상 한 것과 다른
그러나 예
은 상세보기를 다음 대신 직접Fragment
의하는
Fragment
을 보유하고
FrameLayout
있다.
레이아웃 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
자체 사용되는 이유는 무엇입니까? 그 이유는 무엇입니까? 나는 그것을 사용해야합니까?
사실 도움이되었습니다. 필자의 경우, 조각을 대체 할 필요가 없으므로 이제'FrameLayout'을 그대로두고'Fragment'를 직접 사용할 수 있습니다. – Terry