Android: WebView cannot display percent sign%

I am trying to reproduce html and js code in webview. the code contains a% sign, and web browsing returns an error ERROR_BAD_URL.

<style type='text/css'>
test{
width: 100%;
height: 100%;
}
</style>

any idea?

-Z

+3
source share
3 answers

use webview.loadDataWithBaseUrlif .loadDatacausing problems.

+11
source

I came across this myself this weekend. Use "% 25" to make the% character. Your new code should look like ...

<style type='text/css'>
    test{
        width: 100%25;
        height: 100%25;
    }
</style>
+7
source

try it

mWebView.loadDataWithBaseURL(null, html,"text/html", "UTF-8", null); 
+2
source

Source: https://habr.com/ru/post/1794260/


All Articles