英文:
how to prevent resizing of items in recyclerview
问题
我有一个异构的RecyclerView(图像、视频和文本),它运行良好,但问题是当我滚动时,它会根据帖子的高度进行调整大小。那么,我该如何使它像Instagram一样,在Instagram中快速滚动时,即使帖子尚未加载,它们也已经占据了它们的高度,不会重新调整大小。提前感谢!
英文:
I have a heterogeneous recyclerview (Image, video and text) it is working fine but the problem is when i scroll, it resizes according to the height of posts. so how can i make it like instagram as when we rapidly scroll in instagram even though the posts are not loaded but they occupy their height already and not resize, thanks in advance!
答案1
得分: 1
请确保在您的ViewHolders中,当您的ViewHolder更改其大小以适应您传递给它的任何内容时,高度不设置为wrapContent。
我建议使用ConstraintLayout来创建更好的视图。
有关更多信息,请查看文档:
https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout
英文:
make sure that on your ViewHolders height isn't set on wrapContent when it happened your viewHolder change its size to what ever you are passing to it
i recommend to use ConstraintLayout to make better views
see the docs for more info
https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout
答案2
得分: 0
确保被回收的项目的父视图组的高度未设置为 android:layout_height="wrapContent"。
英文:
Make sure the parent view group of the item's height that recycled isn't set to
android:layout_height="wrapContent"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论