Android Recyclerview preload views
<p>Im wondering how I can avoid the little white 'flashing' of the views in a recyclerview when the user scrolls a little faster.<br>
The flashing can be avoided of course by preloading more views outside of the visible screen  </p>

<p>I could not find anything yet how this can be done, although this must be a pretty common task??  </p>

<p>I tried this code from a blog:  </p>

<pre><code>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 &gt; 0) {
            return extraLayoutSpace;
        }
        return DEFAULT_EXTRA_LAYOUT_SPACE;
    }
}
</code></pre>

<p>Then I assigned the LayoutManager to my custom Recyclerview in the constructor by using setLayoutManager()<br>
It is "custom", but I only wanted to set the LayoutManager in the costructor, thats why I overwrote the RecyclerView<br>
Unfortunately, this did not have any effect</p>