Android, Glide shows wrong image for about one second

前端 未结 2 1277
攒了一身酷
攒了一身酷 2021-01-12 15:29

I\'m using Glide library for loading images from URL, which I get from Graph Request (Facebook). It\'s used in RecyclerAdapter. When I\'m scrolling, each ImageView shows wro

2条回答
  •  暖寄归人
    2021-01-12 16:15

    Your "problem" is that the ImageViews you are using are recycled from previous rows (which are disappearing while scrolling). Thus your ImageView in onBindViewHolder already contains a previous image.

    This image is displayed until the network requests (GraphRequest and Glide) for the new image are finished.

    To avoid the problem you have to clear your ImageView before calling getEventCover. This can be done by setting an placeholder image or by setting a transparent image as follows:

    main_image.setImageResource(android.R.color.transparent);
    

提交回复
热议问题