1

I have a recyclerview which populates different types of ViewHolders based on the data provided in the adapter arraylist. In one of the scenarios I have to populate a viewholder that shows HTML text inside a webview. When this viewholder is added, the recyclerview lags while scrolling. If this viewholder is removed then the recyclerview scrolls fine.

Other viewholders need to be update-able since they change UI based on user interactions, and some viewholders add additional objects into the recyclerview when user clicks on the viewholder(expandable recyclerview item). So the position of the viewholders might not be same on every occation.

Is there a way to fix this scrolling issue. Or atleast to pre-load that one particular viewholder and keep it unchanged?

Lino
  • 5,084
  • 3
  • 21
  • 39
Akhil Soman
  • 2,077
  • 2
  • 17
  • 30
  • 2
    Doing what it should be. Poor design idea to show webview in recyclerview – Rasel Jan 01 '20 at 06:59
  • Use `Html.fromHtml` for display HTML text in `TextView` – Chirag Savsani Jan 01 '20 at 07:05
  • hi @ChiragSavsani...can you help me over here --> https://stackoverflow.com/questions/59526045/how-to-run-java-and-xml-code-fetched-from-api-into-another-fragment – Wini Jan 01 '20 at 08:05
  • 1
    Hi Akhil, did you find any solution, same issue coming out in my case – Mohd Saquib Aug 20 '20 at 11:01
  • 1
    @MohdSaquib Sorry for the late reply. What we could understand is that every time the webview was created a new, the lag was created when the recyclerview was trying to determine the height of the webview inside the viewholder. So what we ended up doing is that, on first load after the HTML is loadded, we save the height of the webview. And when next time when the createViewHolder() method is fired we check for whether there is a height already saved against this viewholder. If there is, then we prematurely assign this saved height to the webview. – Akhil Soman Sep 07 '20 at 03:39

0 Answers0