Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird problem on android webview with canvas

I am draw some canvas charts on the android webview, and use javascript to change chart just by hiding and showing, and also change the title by reset its innerHTML.

The title is just a normal html tag "<div id='title'></div>",

The problem is that the page does not render well when I switch charts, for example. when I choosed to display the next chart and change the title's innerHTML, the title seems 'remembered' its previous innerHTML and it looks like one text overlapped another.

If I manually change my phone's orientation, it seems make the webview redraw its content (not refresh), then everything will be fine.

Any idea on this? or can I simulate the orientation change event to make my webview redraw its page to work around it?

like image 316
virsir Avatar asked Jul 10 '10 12:07

virsir


People also ask

Is Android WebView deprecated?

The Android system webview custom cache file has been deprecated and removed in Android 13. New apps and any app updates will now use the operating system default cache location.

Which browser is used in Android WebView?

On Android 7.0, 8.0 and 9.0, Google Chrome handles the embedded browsing functions. On other Android OS versions, web app performance may suffer without WebView enabled.

What is alternative of WebView in Android?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

How do I change WebView settings on Android?

May 18, 2021•HSM ArticleGo to settings > apps and select Chrome application. Tap on Disable (this will disable the chrome browser) Go to Google PlayStore and search for webview. Tap on Android System Webview in the search results.


1 Answers

This issue seems to come up when you are using a transparent background with your webview. Try adding this into your CSS:

body {
    background-color:black;
}

Or whatever you wish your background color to be.

like image 69
wmute Avatar answered Oct 04 '22 21:10

wmute