Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to preload data in WebViews in the children of a RecyclerView?

I have a RecyclerView using the LinearLayoutManager where each of the child cards contains a WebView. I load the data into the WebView using the loadData() method. Things work fine when I'm scrolling down the list, but when I scroll down far enough that the above views get recycled I get issues when I scroll back up.

When the RecyclerView reattaches the above child it reloads the data in the WebView, but it doesn't reload it until the WebView is on the screen. When the WebView loads its data, it pushes all the children below it down the screen. So instead of having the bottom of the WebView slowly appear on screen as I scroll up, the entire WebView jumps on to the screen at the top of the WebView. It's very jarring and not smooth at all.

Is there any way to tell the adapter or layout manager to load the WebViews ahead of time? I'd be happy with my app if the RecyclerView scrolled smoothly, but right now it's pretty much unusable any time I scroll back up.

like image 338
wile_e8 Avatar asked Jul 03 '15 03:07

wile_e8


2 Answers

Try Resizing WebView to Match the Content Size

Also might want to look at, Recycler View – pre cache views

In combo it works pretty good but I'm still trying to improve scrolling.

like image 196
Derek Beattie Avatar answered Sep 23 '22 05:09

Derek Beattie


I know this is an old question, but stumbled upon it when researching another answer. Try to set the item view cache size higher.

RecyclerView.setItemViewCacheSize(int cacheSize)

like image 25
airowe Avatar answered Sep 22 '22 05:09

airowe