且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android支持库23.2版和RecyclerView

更新时间:2023-11-17 18:57:28

当您的RecyclerView行在滚动方向上的大小设置为match_parent时,会发生这种情况.

This occurs when your RecyclerView rows have their size set to match_parent in the scrolling direction.

例如,如果垂直的LinearLayoutManager的RecyclerView每行具有以下布局,则该行现在实际上将与父级的高度匹配.在23.2.0版之前,它仍然会简单地包装内容.

For example, if a RecyclerView with a vertical LinearLayoutManager has the following layout for each row, that row will now actually match the parent's height now. Before version 23.2.0 it would still simply wrap the content.

<View
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

在这种情况下,将高度更改为wrap_content将解决此问题.

In this case, changing the height to wrap_content will resolve the issue.

此问题在公告博客文章中进行了简要提及:

由于此更改,请确保仔细检查 您的商品视图:以前忽略的布局参数(例如 现在将完全遵守滚动方向上的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.