RecyclerView and Picasso images disappear after scrolling

recyclerview items disappear scroll
android-recyclerview content messed up after scrolling
recyclerview scroll up and down data will change
picasso recyclerview
picasso not loading image from url
recyclerview load image from url
glide recyclerview slow
glide loading images each time when scrolling recyclerview

I didn't find an answer here, here and here.

I have an activity that shows list of posts (with or without images). When I scroll down and scroll up or refresh the list using SwipeRefreshLayout some of the images may disapper. I use RecyclerView to show list of posts and Picasso to load images. Here is my adapter binding:

@Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
    // <...>
    if (item.getPhoto() != null) {
        Picasso.with(context)
                .load(item.getPhoto())
                .into(holder.mPostPhoto);
    } else {
        holder.mPostPhoto.setImageDrawable(null);
        holder.mPostPhoto.setVisibility(View.GONE);
    }
}

I send HTTP request to get posts and when I have new data I call PostsAdapter:

public void addAll(List<PostResponse> items) {
    this.items.clear();
    this.items.addAll(items);

    notifyDataSetChanged();
}

In MainActivity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // <...>
    mPostAdapter = new PostAdapter();
    mPosts.setLayoutManager(new LinearLayoutManager(MainActivity.this));
    mPosts.setAdapter(mPostAdapter);

    mPostsSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            updatePosts();
        }
    });

    updatePosts();
}

private void updatePosts() {
    new Api(this).getPosts(new GetPostsCallback(this) {
        @Override
        public void onSuccess(final Paging<PostResponse> paging) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mPostAdapter.addAll(paging.getData());
                    mPostsSwipeRefresh.setRefreshing(false);
                }
            });
        }
    });
}

I find it's pretty basic, I don't understand why images disappear time after time. My list is not long and images resized before the upload to the server, they shouldn't use much memory. And the worst, when they disappear, they don't reload. They may reload only after I scroll down and up...

  • Please explain me why it happens.
  • How can I fix this problem?

Thanks!

I ran into this issue as well, but didn't want to disable the recycling. I found that by explicitly setting the ImageView visibility to View.VISIBLE before making the call to Picasso, the images loaded even after scrolling:

holder.image.setVisibility(View.VISIBLE);
Picasso.with(context)
    .load(imgUrl)
    .into(holder.image);

RecyclerView and Picasso images disappear after scrolling, When I scroll down and scroll up or refresh the list using SwipeRefreshLayout some of the images may disapper. I use RecyclerView to show list of posts and� My listview loads Picasso images slowly. I often have wait on it to download one image, scroll a bit, and wait on it to download the next image in the listview, it doesn't work in advance. Downloaded images also disappear when I scroll back up.

So, apparently RecyclerView was recycling items from my list and for some reason it couldn't reload images after that. Good question "why?"... Maybe because I did something wrong, not sure. This helped me:

recyclerView.getRecycledViewPool().setMaxRecycledViews(0, 0);

Basically you are turning off items recycling. It works for me because I don't render huge lists of items.

Already downloaded images disappear while scrolling upwards in , Hi everyone, My listview loads Picasso images slowly. I often have wait Downloaded images also disappear when I scroll back up. It feels as if Images are reloading in the recyclerview even volley using LruCache class ? Picasso is a image loading library by Square Inc.It makes image loading easier. It also provides disk caching and makes networking easier. For example if you are using Picasso in a adapter it loads image only once and reuses the cached image for the next time.

If you are using if condition in adapter then try below code

    if (model.image == null || model.equals(""))
        viewHolder.ivIndieImage.setVisibility(View.GONE);
    else{
        viewHolder.ivIndieImage.setVisibility(View.VISIBLE);
      }

try to setVisibility visible of the image.

RecyclerView disappearing while loading images � Issue #1449 , RecyclerView disappearing while loading images #1449 I've done a side by side comparison of Picasso and Glide. RecyclerView is another ScrollView and the scrolling is leading the RecyclerView to scroll off the screen. why recyclerView items goning to disappear with scrolling. 276. I am using a recycler view in my app but when I scroll on my recyclerView my items will disappear

You missed one thing in the onBindViewHolder. In the else part you are changing the visibility to View.GONE but in the If part you are not making it visible again. So, in recycler view the views are getting recycled means there data is getting changed but If you modify any property it will remain same for that view and it will be seen in the other items that are being shown using the same recycled view.

Random Glide images disappear on scroll - epoxy, But when I scroll down and then scroll up, a few random viewholders that are The first fragment contains an epoxy recyclerview which displays carousels : Displaying images is easiest using a third party library such as Picasso from Square which will download and cache remote images and abstract the complexity behind an easy to use DSL. Before Using Picasso , do not forget to add internet permission in the manifest file . Setup Permission. Adding Internet Permission to our Manifest.xml file:

I was able to fix this issue by removing the resize and center crop methods of the same, somehow they were taking too much memory and it was leading to messing up the image loading process

Recyclerview automatically scrolls to the top when data is loaded, May 21, 2018 � Now, the RecyclerView will scroll but it will not be smooth. is scrolled to the bottom, so you have to scroll up and then back down for it to disappear. Apr 21, 2018 � How to Add Multiple Images to Horizontal Scroll View in Android I suggest you to use image loader library like Picasso or Glide to make sure� i am fetching image from drawable folder in recyclerview and i am using picasso library but my scrolling is not smootly. Copy link Quote reply maulikdadhaniya commented Sep 11, 2018

How to optimize memory consumption when using Glide, In most cases, when you use Glide to load images you don't have to worry about releasing When RecyclerView is being scrolled, views that were created at the top and are now off-screen are being recycled. since the item will be recycled only after it fully disappeared from the screen. Using Picasso? Adding images from the internet to RecyclerView. Our list just looks sad without images and we need to add them, so we will use Picasso library made by Square. This library makes working with images easier, therefore, we will use its ability to load images from the web. All we need is a simple line of code, but let's go step by step.

Picasso Tutorial for Android: Getting Started, Another thing you can do with Picasso is resizing images sure that each item in your RecyclerView occupies roughly half the screen. Now build and run your app and scroll down to see some of the results:. After some research online I found a fix - If I create a Picasso instance with single threaded executor, the problem goes away, but I don't understand why. As I understand Picasso uses a thread pool to download the images and after the downloading is finished it uses the main thread to load them.

RecyclerView for Android Beginners, RecyclerView is a component that displays data in different ways. It is made with contemporary techniques to make scrolling smooth and Our list just looks sad without images and we need to add them, so we will use Picasso library made by Animations of items when they appear or disappear; Paging and loading data� Recyclerview automatically scrolls to the top when data is loaded. Recyclerview automatically scrolls to the top when data is loaded

Comments
  • it is hard to say why is this happening with the code you posted. Could you share a little bit more ? Do you have any specific configuration policy for picasso?
  • @Blackbelt please see an update. I don't have any specific configuration for anything. It's very basic: get posts from the server, each post has image url, use picasso to load image to ImageView by url.
  • it looks good - if you log item.getPhoto() ?
  • @Blackbelt I checked item.getPhoto() it's there...
  • this is the right answer , please accept it so that others know it works
  • @Billy Brawner, man thank you so much.. you saved my day! This should be the correct answer
  • why would you even use recycler view if you don't want to recycle things
  • @HuzefaGadi I do want to use recyclerView. The issue is that it doesn't work as expected..