android - 当回收站视图中的项目数量很少时,协调器布局太大
问题描述
我在 Coordinator 布局中遇到 RecyclerView 问题。如果 recycler view 中的 item 数量较少,则 Coordinator 的 size 大于 screen。滚动到最后,recycler view的空间+额外空间就是屏幕高度的大小。这是正常行为吗?还是有办法解决?如果我将回收器高度设置为“match_parent”,那么整个回收器视图就是屏幕的大小......
编辑:当没有足够的项目时,我希望视图不要滚动。并且如果屏幕下方有 1-2 个项目,则回收器不应与整个屏幕一样高,而只能滚动少数项目。
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity"
android:background="#dddddd">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp"
android:background="#777777">
<FrameLayout
android:id="@+id/cardMenu"
android:layout_width="match_parent"
android:layout_height="300dp"
android:paddingTop="16dp"
android:orientation="vertical"
app:layout_scrollFlags="scroll">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#fff"
android:text="Red Dwarf characters"/>
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:background="#aaaaaa"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>
解决方案
推荐阅读
- javascript - React-responsive-modal:模式打开时更改背景颜色
- java - Spring MVC Post 不工作,客户端挂起
- php - PDO 基于 WHERE 计算行值
- php - 如何在三个不同的表中搜索关键字
- java - 返回构成 Google 地图路径的坐标。
- arrays - 从文本文件创建数组或列表并将值存储在标签中(VB.net)
- react-native - mobx 在对象深处丢失属性
- jquery - 无法将 JQuery 导入 TypeScript 文件
- ios - 请求权限时设置标题?
- php - 编辑后关于 magento 的关于我们的页面没有改变