android - 具有 2 个回收站视图的协调器布局
问题描述
我想用这个布局构建一个 android 片段:
- 屏幕的上半部分是一个水平滚动的 RecyclerView。
- 屏幕的下半部分是一个垂直滚动的 RecyclerView。
当底部 RecyclerView 向底部滚动时,我希望顶部的 RecyclerView 折叠和隐藏(并在底部视图滚动到顶部时打开)。
协调器布局似乎是答案,但我遇到的每个示例都使用 AppBarLayout 作为顶部。包含该片段的活动已经显示了一个应用栏;我不想修改它。
我将如何在 CoordinatorLayout 中实现这两个 RecyclerView 设置而不解决应用栏?
解决方案
您可以使用具有垂直方向的 a NestedScrollView
, a作为 of 的子级,并将两个s 添加为 of 的子级LinearLayout
NestedScrollView
RecyclerView
LinearLayout
样本
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
推荐阅读
- prestashop-1.7 - Prestashop 多面搜索自定义值重复每个产品如何
- html - CSS 从 ::after 更改元素的文本颜色
- encryption - 如何使用加密和解密脚本进行复制和粘贴以传输密码?
- c++ - 如何处理用于将 MariaDB 连接到 C++ 应用程序的 dll 和 lib 文件?
- database - Mongo 服务器不是由 cmd mongod --dbpath /Users/mayankpatel/data/db 启动的
- c - 我不知道我们如何得到以下程序的输出 0 5 0
- python - 如何安排在 AWS 上运行自动将输出文件上传到 GitHub 的 python 文件?
- hyperledger-fabric - HLF :网络上的受限频道创建策略
- java - 如何在 Java 中减少有限的流(例如 ArrayList)?
- node.js - Phusion 乘客 + apache + nodejs 启动应用程序 w cli args