向上滑动后,RecyclerView v23.2.0和空白 [英] RecyclerView v23.2.0 and blank space after swiping up
问题描述
我将支持库更新为23.2.0.并将recyclerView的高度更改为wrap_content,如博客
I updated the support library to 23.2.0. and changed the height of the recyclerView to wrap_content as explained in the blog here :
RecyclerView小部件为创建列表和网格以及支持动画提供了高级而灵活的基础.此版本为LayoutManager API带来了令人兴奋的新功能:自动测量!这使RecyclerView可以根据其内容的大小自行调整大小.这意味着以前不可用的方案(例如,将WRAP_CONTENT用于RecyclerView的尺寸)现在是可能的.您会发现所有内置的LayoutManager现在都支持自动测量.
The RecyclerView widget provides an advanced and flexible base for creating lists and grids as well as supporting animations. This release brings 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.
编辑/添加的注释:我必须这样做,因为在更新"match_parent"完成了应做的工作之后,它将cardviews的高度向下延伸到了底部,所以我最终每页只有一个cardview.
edited/added comment : I had to do this because after the update 'match_parent' did what it's supposed to do, it stretched the cardviews height down to the bottom, so I ended up having one cardview per page.
但是现在刷卡后,新创建的卡片视图之间又有了多余的空间.
But now after swiping up the newly created cardviews have the unwanted space between them again.
让我进一步澄清一下:
- 首次加载页面时,可以看到5张卡片视图,并且显示正确.
- 我向上滑动并显示一个新的Cardview号6
- 进一步刷卡会显示Cardview 7号,但6号和7号之间有空白
- 所有新创建的卡片视图之间都有很大的空白
有人遇到过这种行为吗?
Has anyone encountered this behavior ?
推荐答案
我发现了这个错误.
在卡片视图所在的布局文件中,我还必须将周围的RelativeLayout的layout_height属性修改为WRAP_CONTENT.
In the layout file where the cardview is in, I had to modify the surrounding RelativeLayout's layout_height attribute to WRAP_CONTENT as well.
有趣的是,我将RecyclerView的layout_height改回了MATCH_PARENT,它仍然可以按需工作.
Interesting part is, I changed the layout_height of RecyclerView back to MATCH_PARENT and it still worked as desired.
这篇关于向上滑动后,RecyclerView v23.2.0和空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!