Preview Android Recyclerview Views

I am wondering how I can avoid a little white โ€œblinkingโ€ of views in recycliewiew mode when the user scrolls a little faster.
Blinking can be avoided, of course, by preloading more views outside the visible screen.

I still could not find how to do this, although this should be a fairly common task?

I tried this code from the blog:

public class PreCachingLayoutManager extends LinearLayoutManager {
    private static final int DEFAULT_EXTRA_LAYOUT_SPACE = 600;
    private int extraLayoutSpace = -1;
    private Context context;

    public PreCachingLayoutManager(Context context) {
        super(context);
        this.context = context;
    }

    public PreCachingLayoutManager(Context context, int extraLayoutSpace) {
        super(context);
        this.context = context;
        this.extraLayoutSpace = extraLayoutSpace;
    }

    public PreCachingLayoutManager(Context context, int orientation, boolean reverseLayout) {
        super(context, orientation, reverseLayout);
        this.context = context;
    }

    public void setExtraLayoutSpace(int extraLayoutSpace) {
        this.extraLayoutSpace = extraLayoutSpace;
    }

    @Override
    protected int getExtraLayoutSpace(RecyclerView.State state) {
        if (extraLayoutSpace > 0) {
            return extraLayoutSpace;
        }
        return DEFAULT_EXTRA_LAYOUT_SPACE;
    }
}

Then I assigned the LayoutManager to my custom Recyclerview in the constructor using setLayoutManager ().
This is โ€œcustomโ€, but I just wanted to set the LayoutManager to a costructor, which is why I rewrote the RecyclerView
unfortunately, it had no effect

+4
1

RecyclerView - API , , , , , , , . -.

, , https://blog.workable.com/recyclerview-achieved-60-fps-workables-android-app-tips/

, , , , .

- , .

+3

Source: https://habr.com/ru/post/1659508/


All Articles