Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: when / why should I use FrameLayout instead of Fragment?
    primarykey
    data
    text
    <p>I am building a layout for large screens, that is supposed to consist of 2 different parts, a left one and a right one. For doing that I thought using 2 Fragments is the right choice. </p> <p>Then I had a look on the example of the navigation with the <strong>Master/Detail-Flow</strong>. It has a 2-pane layout, where on the right is the navigation, and on the left is the detail view.</p> <p>But in that example, different from what I expected to see, for the detail view there is a <code>FrameLayout</code> that then holds a <code>Fragment</code>, instead of a <code>Fragment</code> directly.</p> <p>The layout XML looks like this (an example):</p> <pre><code>&lt;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" &gt; &lt;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" /&gt; &lt;FrameLayout android:id="@+id/workstation_detail_container" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>My question now is: why is a <code>FrameLayout</code> used instead of the <code>Fragment</code> itself for the detail view? What is the reason or the advantage? Should I use it too?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload