RecyclerView внутри ViewPager внутри NestedScrollView - не работает хорошо - PullRequest
0 голосов
/ 10 марта 2020

Проблема в том, что NestedScrollView не прокручивается, когда у RecyclerView есть данные.

<androidx.core.widget.NestedScrollView ...
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">

   ...
<androidx.viewpager.widget.ViewPager
     android:id="@+id/vp_perfil"
     android:layout_width="match_parent"
     android:layout_height="600dp"
     android:background="#8E5252">
</androidx.viewpager.widget.ViewPager>

</androidx.core.widget.NestedScrollView>

Это похоже на NestedScrollView - нормальный макет и не может установить ViewPager в wrap_content, потому что он работает только как match_parent.

1 Ответ

0 голосов
/ 11 марта 2020

Попробуйте, как показано ниже:

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

    <androidx.core.widget.NestedScrollView
        android:id="@+id/sv_top"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/ll_product_detail_bottom"
        android:layout_alignParentTop="true"
        android:overScrollMode="never">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/padding_5">

            <androidx.viewpager.widget.ViewPager
                android:id="@+id/pd_pager"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true" />

            <com.viewpagerindicator.CirclePageIndicator
                android:id="@+id/pd_indicator"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:gravity="bottom"
                android:padding="@dimen/padding_10"
                app:centered="true"
                app:fillColor="@color/colorPrimary"
                app:pageColor="@android:color/darker_gray"
                app:snap="false" />
        </RelativeLayout>
    </androidx.core.widget.NestedScrollView>
</RelativeLayout>

Надеюсь, это поможет вам

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...