In my Nougat device, webview inside RecyclerView is blank sometimes. When I scroll slowly and then go back to webview item content disappear. There is no issue on devices below Android N. Android N uses Chrome as the default browser for apps. So I thought there might be a bug in Chrome so I raise a bug in chrome portal as well. There are a couple of related question in SO but that didn't solve my problem. So is there a way in Android webview setting which can solve this problem? I have written detail description in the bug link.
Bug link: click here
My onBindViewHolder method code for WebView is
final VHItem vhItem = (VHItem) holder;
vhItem.webViewChild.getSettings().setUseWideViewPort(false);
vhItem.webViewChild.getSettings().setJavaScriptEnabled(true);
vhItem.webViewChild.loadData("<body>" + html + "</body>", "text/html;charset=utf-8", "utf-8");
where
html is the html string
Update
They have fixed the issue. If you are still having the same problem try updating your Android chrome version to 61 or above.
A nested RecyclerView is an implementation of a RecyclerView within a RecyclerView. An example of such a layout can be seen in a variety of apps such as the Play store where the outer (parent) RecyclerView is of Vertical orientation whereas the inner (child) RecyclerViews are of horizontal orientations.
It was removed in version 7.0 of the Android Gradle plugin.
setHasFixedSize(true) means the RecyclerView has children (items) that has fixed width and height.
A RecyclerView. ViewHolder class which caches views associated with the default Preference layouts. A ViewHolder describes an item view and metadata about its place within the RecyclerView.
For a start webview consumes memory because it load has to load and render html data. Rather than using a webview in a recycler view, I think it would be better if you implemented it either of these two ways:
Using a webview might seem the easy way to implement whatever you are trying but trust me, the drawbacks outweight the benefit. So its just best to avoid it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With