如何使RecyclerView更新其布局? [英] How do I make RecyclerView update its layout?
问题描述
我有一个RecyclerView
,其中包含一堆自定义视图,这些视图可能会在一段时间后更改高度,因为它们包含ImageView
,这些异步地加载其图像.尽管我在ImageView
上调用了forceLayout
,并且RecyclerView
用setHasFixedSize(false)
初始化了,但RecyclerView
并未适应这种布局更改. 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 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屋!