Note that there are some explanatory texts on larger screens.

plurals
  1. POSet fragments' positions in android activities
    text
    copied!<p>I have a fragment that should be shown in an activity under another fragment </p> <p>In the xml of the fragment I tried to use:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/second_fragment" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10sp" android:layout_below="@id/first_fragment"&gt; &lt;TextView android:id="@+id/mytext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" " android:focusable="false" android:clickable="false" android:textSize="20sp" android:padding="5sp" android:layout_centerHorizontal="true"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>(please note android:layout_below="@id/first_fragment" in the layout tag)</p> <p>I have also tried this:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/first_fragment" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10sp"&gt; &lt;TextView android:id="@+id/mytext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" " android:focusable="false" android:clickable="false" android:textSize="20sp" android:padding="5sp" android:layout_centerHorizontal="true" android:layout_below="@id/first_fragment"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>(please note android:layout_below="@id/first_fragment" in the TextView tag)</p> <p>in both cases the application compile and run but the second fragment is shown on the top of the screen instead of after the first one.</p> <p>Please consider that I'm adding the fragments programmatically by using FragmentTransaction and I add the second fragment after having added the first one, but in the same transaction</p> <p>Can you please tell me what's wrong?</p> <p>Thank-you</p>
 

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