在23.2.0之后查看具有较大空白空间的物品 [英] RecyclerView items with big empty space after 23.2.0

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

问题描述

在我的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之后查看具有较大空白空间的物品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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