Android – use coordinator layout in Recycle Bin view
•
Android
How to make the recycler view move with the viewpager? The recycler view does not move with the view pager. I have used the coordinator layout and collapsed toolbar layout, but the recycler view is still scrolling independently rather than in the viewpager. The view pager is collapsing, but only in this specific area
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="150dp"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:id="@+id/slider_pager">
</android.support.v4.view.ViewPager>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:id="@+id/list_hotels"
android:background="@color/back1">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Please help me move them up and down together
resolvent:
The application bar / toolbar section looks good. However, it is unnecessary for you to wrap recyclerview in nestedscrollview
Completely delete nestedscrollview and declare your recyclerview as follows:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:id="@+id/list_hotels"
android:background="@color/back1"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
If you still have problems, please update your problem with the new XML layout
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码