RecyclerView在使用notifyItemRemoved时,LayoutManager中的方法onMeasure()不会运行

时间:2016-01-26 17:13:11

标签: android android-recyclerview

我创建了一个可以自动调整layout_height的CustomGridLayoutManager。

但是,当我使用方法notifyItemRemoved()时,LayoutManager中的onMeasure()不会运行。

我搜索了源代码,但在LayoutManager中似乎没有view.invalidate()postInvalidate()等方法,而LayoutManager中的方法requestLayout()正在调用RecyclerView.requestLayout(),它不起作用。

因此,如果我想通知LayoutManager运行它的onMeasure()方法,我该怎么办?

1 个答案:

答案 0 :(得分:0)

最后我发现我有一行recyclerView.setHasFixedSize(true)......

我不知道何时添加此代码并删除它,它运行良好。