Размещение TextView по верх ViewPager
Есть ViewPager и TextView нужно сделать так чтобы TextView отображался по верх ViewPager. Я пробовал RelativeLayout и ConstraintLayout что бы реализовать это но постоянно картинка которая находиться в ViewPager перекрывает TextView. Как сделать чтобы TextView был над ViewPager?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text_o"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="center"
android:paddingHorizontal="2dp"
android:textColor="@color/color_2"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/color_2" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="300dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dp"
android:background="@color/color_2" />
</RelativeLayout>
Ответы (1 шт):
Автор решения: AVRamones
→ Ссылка
Разместите TextView в самом конце вашего RelativeLayout. Чем ниже элемент в списке, тем выше остальных элементов (по оси Z) он находится на разметке.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
...
...
<TextView
android:id="@+id/text_o"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="center"
android:paddingHorizontal="2dp"
android:textColor="@color/color_2"
android:textStyle="bold" />
</RelativeLayout>