У меня есть фрагмент, который должен быть показан в действии под другим фрагментом
В xml фрагмента, который я пытался использовать:
<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">
<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"/>
</RelativeLayout>
(обратите внимание на android: layout_below =«@ id / first_fragment» в теге макета)
Я также пробовал это:
<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">
<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"/>
</RelativeLayout>
(обратите внимание на android: layout_below = "@ id / first_fragment" в теге TextView)
в обоих случаях приложение компилируется и запускается, но второй фрагмент отображается вверху экрана, а не после первого.
Обратите внимание, что я добавляю фрагменты программноиспользуя FragmentTransaction, и я добавляю второй фрагмент после добавления первого, но в той же транзакции
Подскажите, пожалуйста, в чем дело?
Спасибо