如何让 RecyclerView 更新其布局? [英] How do I make RecyclerView update its layout?
问题描述
我有一个带有一堆自定义视图的 RecyclerView
,它们可能会在一段时间后改变高度,因为它们包含异步加载图像的 ImageView
s.尽管我在 ImageView
和 RecyclerView
上调用了 forceLayout
,但 RecyclerView
不会接受此布局更改用 setHasFixedSize(false)
初始化.ImageView
的所有容器父级都设置了 android:layout_height="wrap_content"
.
I have a RecyclerView
with a bunch of custom views which may change height after a while, because they contain ImageView
s which load their image asynchronously. The RecyclerView
does not pick up on this layout change, although I call forceLayout
on the ImageView
, and the RecyclerView
is initialized with setHasFixedSize(false)
. All container-parents of the ImageView
have set android:layout_height="wrap_content"
.
如何让 RecyclerView
更新其布局?使用 good'ol ListView
这不是问题.
How can I make the RecyclerView
update its layout? With good'ol ListView
this was not a problem.
推荐答案
Google 终于在 支持库 v23.2.使用 SDK 管理器更新您的支持存储库后,通过更新 build.gradle
中的这一行来修复问题:
Google has finally fixed this in support library v23.2. Issue is fixed by updating this line in build.gradle
after updating your support repository with the SDK Manager:
compile 'com.android.support:recyclerview-v7:23.2.0'
这篇关于如何让 RecyclerView 更新其布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!