Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To hopefully explain, take a look at the <a href="http://developer.android.com/guide/topics/fundamentals/fragments.html#Design">Design Philosophy</a> for Fragments in the Dev Guide.</p> <p>If you look at the image, to the left it shows how a phone would show an intial Activity A which would then start Activity B when an item in a list is selected.</p> <p>To the right, however, it is showing how those two Activities can be shown as Fragments at the same time. Notice Fragment A is taking 1/3 of the screen and Fragment B is filling 2/3 of the screen.</p> <p>Now look at the XML for that layout from <a href="http://developer.android.com/guide/topics/fundamentals/fragments.html#Adding">Adding a fragment to an activity</a> from the same Dev Guide article...</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;fragment android:name="com.example.news.ArticleListFragment" android:id="@+id/list" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" /&gt; &lt;fragment android:name="com.example.news.ArticleReaderFragment" android:id="@+id/viewer" android:layout_weight="2" android:layout_width="0dp" android:layout_height="match_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>You can see that both Fragments have a <code>layout_width</code> of 0dp but they also each have a <code>layout_weight</code> attribute. The first has a weight of 1 and the second a weight of 2.</p> <p>In short, when using a layout like this, setting the 'width' to be 0 means you don't want to explicitly enforce a width and that the OS should work out the relative widths as fractions of total weight. In other words 1+2=3 (total weight) but the first Activity wants a width of 1 / total weight = 1/3 of the screen width and Fragment B wants 2 / total width = 2/3 of the screen width.</p> <p>Now suppose you add a third fragment which also has width=0dp and weight=2. In this case, the total weight is 1+2+2=5 and the first fragment will have a relative width of 1/5 and the other two fragments 2/5 of the screen or 20% / 40% / 40%.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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