Search code examples
androidandroid-listviewandroid-webviewmathjax

WebViews inside ListView with MathJax


I have a application which must render MathJax equations and therefore I must use WebView layout because of lot of JavaScript code on MathJax side and many images that are dynamically displayed from MathJax CDN service (all handled by MathJax JS library).

It's working fine with single WebView layout and everything renders just fine - but the problem appears when I need to display the search results from my web API and every search result includes some MathJax code - you can imagine it as a Google Search results but with MathJax code/equations inside.

The first thing that crossed my mind is ListView with a WebView inside each row - but it's very insufficient and I'm putting scrollable webView inside scrollable listView, not a good idea. Also the webView renders each time I scroll a little bit, maybe I could use some cache to cache rendered WebView's but I'm not sure...

Are there any suggested alternatives? Thanks.


Solution

  • You could render the webview into a bitmap, and keep these bitmaps cached. You can do it while it is visible, like here: Rendering Android webview to bitmap, html5 javascript , callback issue or do it in the background, like here: Drawing offscreen WebView to bitmap