Android Recyclerview Below Toolbar
I have a custom RecyclerView and a toolbar which hide when scrolling down and appears when scrolling up. I have a problem about the position of RecyclerView, it is below the Toolba
Solution 1:
Try this:
<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:id="@+id/coordinatorLayout"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><android.support.v7.widget.RecyclerViewandroid:id="@+id/recyclerView"android:layout_width="match_parent"android:layout_height="match_parent"app:layout_behavior="@string/appbar_scrolling_view_behavior"/><android.support.design.widget.AppBarLayoutandroid:id="@+id/appBarLayout"android:layout_width="match_parent"android:layout_height="wrap_content"><android.support.v7.widget.Toolbarandroid:id="@+id/toolbar"android:layout_width="match_parent"android:layout_height="?attr/actionBarSize"android:background="?attr/colorPrimary"app:layout_scrollFlags="scroll|enterAlways" /></android.support.design.widget.AppBarLayout></android.support.design.widget.CoordinatorLayout>
I have removed the ViewPager and added scrolling behavior to RecyclerView
Solution 2:
If Adding a scrolling behavior does not fix your issue
app:layout_behavior="@string/appbar_scrolling_view_behavior"
THEN TRY THIS
I had to give padding to recyclerview which is equivalent to the toolbar/actionbar(app bar) height.
android:paddingTop="?attr/actionBarSize"
add the above line to the recyclerview xml file
Solution 3:
When I have included RecyclerView from another layout the same problem occurred. I added this following line on recyclerview and the problem no longer persists.
app:layout_behavior="@string/appbar_scrolling_view_behavior"
Missing this above line will make this problem.
Solution 4:
You need to add this attribute to your RecyclerView:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
i.e.:
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
Solution 5:
trying adding this line in the ReyclerView
android:layout_marginTop="?attr/actionBarSize"
Post a Comment for "Android Recyclerview Below Toolbar"