在recyclerview中图像闪烁的Android图像

san*_*oli 2 android gridview android-recyclerview

每次在recyclerview中更新图像列表时都会出现轻微的图像闪烁,我在GridView中面临同样的问题,这是通过在这样的持有者中设置图像url的标记来解决的,

//for solving image flicker
if(contentViewHolder.ivPhoto.getTag()==null || (!contentViewHolder.ivPhoto.getTag().equals(currentMoment.getThumbnailUrl()))){
            mImageLoader.displayImage(currentMoment.getThumbnailUrl(), contentViewHolder.ivPhoto);
        }

        contentViewHolder.ivPhoto.setTag(currentMoment.getThumbnailUrl());
Run Code Online (Sandbox Code Playgroud)

这在gridview中工作得很好,但是在回收者视图的情况下它没有解决图像闪烁,有人可以建议我如何在回收者视图的情况下停止图像闪烁吗?

Rat*_*ore 5

如果要更改所有列表项,则仅使用notifyDataSetChanged.在其他情况下,你应该使用: -

  • notifyItemChanged(INT)
  • notifyItemInserted(INT)
  • notifyItemRemoved(INT)

有关更多信息,请参阅以下链接(官方文档): - https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyDataSetChanged%28%29