Настройте RecyclerView в ViewPager - PullRequest
0 голосов
/ 30 апреля 2020

У меня ViewPgaer реализован так:

activity_main. xml:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.viewpager.widget.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="fixed"
        app:tabGravity="fill"
        tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

И фрагмент реализован так:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvNotes"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>

Проблема в том, что RecyclerView теперь охватывает мои вкладки:

Elem1 covers tabs

Мой вопрос заключается в том, как я могу расположить RecyclerView (и любой другой макет), чтобы не закрывать вкладки?

1 Ответ

0 голосов
/ 30 апреля 2020

Добавьте маржу Top около 50dp к вашему RecyclerView в файле xml. Кроме того, отрегулируйте значение поля Top в соответствии с вашими потребностями интерфейса.

...