RecyclerView blinking after notifyDatasetChanged()

前端 未结 18 1759
悲&欢浪女
悲&欢浪女 2020-12-07 16:20

I have a RecyclerView which loads some data from API, includes an image url and some data, and I use networkImageView to lazy load image.

@Override
public vo         


        
18条回答
  •  广开言路
    2020-12-07 17:02

    for my application, I had some data changing but I didn't want the entire view to blink.

    I solved it by only fading the oldview down 0.5 alpha and starting the newview alpha at 0.5. This created a softer fading transition without making the view disappear completely.

    Unfortunately because of private implementations, I couldn't subclass the DefaultItemAnimator in order to make this change so I had to clone the code and make the following changes

    in animateChange:

    ViewCompat.setAlpha(newHolder.itemView, 0);  //change 0 to 0.5f
    

    in animateChangeImpl:

    oldViewAnim.alpha(0).setListener(new VpaListenerAdapter() { //change 0 to 0.5f
    

提交回复
热议问题