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