23.2.0 后具有大空白空间的 RecyclerView 项目 [英] RecyclerView items with big empty space after 23.2.0

查看:26
本文介绍了23.2.0 后具有大空白空间的 RecyclerView 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 RecyclerView 中更新到 v23.2.0 后,我的项目之间有巨大的垂直空白空间.

After update to v23.2.0 in my RecyclerView I have items with huge empty vertical space, between the items.

我的项目布局非常简单:

My item layout is very simple:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="match_parent"                                    
       android:orientation="vertical" >

推荐答案

根据 文档

23.2.0 版本中,LayoutManager API 有一个令人兴奋的新功能:自动测量
这允许 RecyclerView 根据其内容的大小调整自身的大小.这意味着以前不可用的场景,例如将 WRAP_CONTENT 用于 RecyclerView 的维度,现在可以实现.
您会发现所有内置的 LayoutManager 现在都支持自动测量.

With the release 23.2.0 there is an exciting new feature to the LayoutManager API: auto-measurement!
This allows a RecyclerView to size itself based on the size of its contents. This means that previously unavailable scenarios, such as using WRAP_CONTENT for a dimension of the RecyclerView, are now possible.
You’ll find all built in LayoutManagers now support auto-measurement.

由于此更改,请务必仔细检查项目视图的布局参数:以前忽略的布局参数(例如 MATCH_PARENT在滚动方向)将现在完全尊重.

Due to this change, make sure to double check the layout parameters of your item views: previously ignored layout parameters (such as MATCH_PARENT in the scroll direction) will now be fully respected.

在您的项目布局中,您必须更改:

In your item layout you have to change:

android:layout_height="match_parent"

android:layout_height="wrap_content" 

这篇关于23.2.0 后具有大空白空间的 RecyclerView 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆