如何使回收者视图与viewpager一起移动 回收器视图不随视图寻呼机一起移动。我使用了具有折叠工具栏布局的协调器布局,但仍然是回收器视图独立滚动而不是使用viewpager。视图寻呼机正在折叠,但仅限于该特定区域..
<?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>
请帮我一起上下移动。
答案 0 :(得分:3)
应用栏/工具栏部分看起来不错。但是,您RecyclerView
包含NestedScrollView
,这是不必要的。
完全删除NestedScrollView
并按照以下方式声明RecyclerView
:
<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"/>
如果仍有问题,请使用新的XML布局更新您的问题。