Changes of RecyclerView in Android Support Library 23.2.0



The RecyclerView widget provides an advanced and flexible base for creating lists and grids as well as supportinganimations. This release brings an exciting new feature to the LayoutManager API: auto-measurement! This allows aRecyclerView 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.

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.

If you have a custom LayoutManager that does not extend one of the built in LayoutManagers, this is an opt-in API - you’ll be required to call setAutoMeasureEnabled(true) as well as make some minor changes as detailed in the Javadoc of the method.

Note that although RecyclerView animates its children, it does not animate its own bounds changes. If you would like to animate the RecyclerView bounds as they change, you can use the Transition APIs.
RecyclerView控件为创建现象列表和网格列表提供了一个高级并且扩展性强的基础,并且还有动画的支持。这个版本为LayoutManager API带来了一个令人兴奋的特性:自动测量!这将使得RecyclerView基于它的内容控制其大小。这意味着以前不能置信的场景成为现实,比如:使用WRAP_CONTENT作为RecyclerView的属性。现在所有的LayoutManager内置实现都已经支持自动测量。

由于这个变化,请再检查一次你的item View的布局参数:之前被忽略掉的布局参数(比如滚动方向的MATCH_PARENT参数)现在都将会完全起作用。


注意,虽然RecyclerView会给它的子View加上动画效果,它并不会改变自己的Bounds。如果你希望给RecyclerView的bounds加动画效果,你需要使用Transition API