Android WebView renders blank/white, view doesn't update on css changes or HTML changes, animations are choppy

后端 未结 9 1439
不知归路
不知归路 2020-11-27 10:25

When ever I make a css class change, the changes don\'t always appear. This appears to happen when I have a touch event that adds something like a down class name to a butto

相关标签:
9条回答
  • 2020-11-27 10:46

    I had this problem because onPageStared and onPageFinished I show and hide a loading animation.

    Since was injecting JS do my menus and stuff from the original website and noticed that injecting JS on onPageFinished force the webview to draw contents. Here is a example of what you can add at the end of onPageFinished

    view.loadUrl("javascript:(function() { var select = document.getElementsByClassName('something')[0]\r\n" + 
                                "                     if(select)" +
                                "                       select.style.display = 'none';})()");
    
    0 讨论(0)
  • 2020-11-27 10:47

    Just clear the cache of webView in oncreate() and it works for me.

    webView.clearCache(true);
    
    0 讨论(0)
  • 2020-11-27 10:51

    Please also see my answer at WebView fails to render until touched Android 4.2.2 , The idea is to export @Olivier's function to JavaScript so you can trigger invalidates from JS in sensible parts ... My god, yet another more hack !! :)

    0 讨论(0)
提交回复
热议问题