Recyclerview contents overlap scrolling Appbar after implementing SwipeRefreshLayout

21 views Asked by At

I have a recyclerview with scrolling appbar, everything work as expected until swiperefresh layout is implemented. The contents of recyclerview overlap appbar as the image below. don't know what is wrong. Without swiperfresh layout, recyclerview can stay below the appbar.

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".Knowledge"
android:orientation="vertical">



    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp"
        android:fitsSystemWindows="true"
        >

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:titleTextColor="@color/black"

            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:id="@+id/swipeRefreshLayoutActivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            tools:listitem="@layout/fragment_item"
            android:nestedScrollingEnabled="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            />


</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

enter image description here

0

There are 0 answers