在回收者视图中使用协调器布局

罗希特·米什拉(Rohit Mishra)

如何使Recycler视图随ViewPager一起移动Recycler视图不随View Pager一起移动。我已经使用协调器布局和折叠的工具栏布局,但是回收者视图仍在独立滚动,而不是在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>

请帮助我将它们一起上下移动。

克里斯·拉森

应用栏/工具栏部分看起来还不错。但是,您可以将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布局更新您的问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么在 android 中使用回收视图修复协调器布局底部的按钮

具有 2 个回收器视图的协调器布局

回收者视图中的回收者视图

在卡片视图中使用浮动按钮并在回收者视图中应用该卡片时出现错误

如何在框架布局中使用协调器布局?

在“回收者”视图中膨胀

使用 RecyclerView 在协调器布局中滚动某些视图

在回收者视图的适配器内的单个项目视图中使用ViewModel方法是否很好?

如何在android studio的屏幕中使用回收器视图和相对布局

如何在回收站视图中使用图像选择器

尝试从要在回收器视图中使用的 Property Animator 重置值

使用“回收者”视图中的按钮打开地图

如何在android中使用片段显示回收者视图

从API在回收者视图中传递数据

Android:从回收者视图中删除空行

回收者视图中的setOnClickListener崩溃

在回收者视图中显示广告

回收者视图中的空对象引用

无法在回收者视图中设置数据

回收者视图中的项目重叠

在回收者视图中跳过项目

回收者视图中的空列表项

如何使用视图分页器向协调器布局添加底视图?

如何使用 gridlayoutmanager 在回收器视图中离散滚动?

使用Glide在回收器视图中加载图像

如何自定义回收者视图的网格布局管理器?

如何在回收者视图中从所有号码选择器中获取价值?

图像在回收器视图中重复

检测回收器视图中显示的项目