RecyclerView SwipeRefreshLayout прокрутка не работает - PullRequest
0 голосов
/ 30 сентября 2018

Я пытаюсь реализовать список с помощью SwipeRefresh и RecyclerView, однако, используя SwipeRefreshLayout прокрутку блоков по списку.Мой макет XML выглядит следующим образом:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh_contracts"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!--<android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">-->

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/list_contracts"/>

        <!--</android.support.v4.widget.NestedScrollView>-->

    </android.support.v4.widget.SwipeRefreshLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/btn_show_filters"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@drawable/ic_filter_list_black_24dp"
        android:tint="@android:color/white"/>

</android.support.design.widget.CoordinatorLayout>

Как видно из закомментированной части, я также пытался использовать NestedScrollView, но это тоже не сработало.

Всопровождающий исходный файл java. Я только устанавливаю менеджер раскладки и адаптер для просмотра перечня, а также прослушиватель событий для действия по обновлению.

Заранее спасибо.

1 Ответ

0 голосов
/ 30 сентября 2018

Попробуйте это:

<android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh_contracts"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:id="@+id/list_contracts"/>

    </android.support.v4.widget.SwipeRefreshLayout>

Изменение высоты и ширины:)

...