HTML file(test.html) is
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link href="bootstrap.css" rel="stylesheet" type="text/css"/>
<link href="bootstrap-responsive.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h1>Hello World!!!</h1>
<a class="btn btn-primary btn-large">
Learn more
</a>
</body>
</html>
HTML and bootstrap css files are placed in assets folder. If I open the HTML file in IE/Firefox, it is displayed correctly. But Android WebView does not render this properly
Code for WebView is
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
String url = "file:///android_asset/test.html";
webView.loadUrl(url);
IE renders it like this
WebView renders it like this
What is wrong?
Add this line
webView.getSettings().setDomStorageEnabled(true);
Tested on emulator - Android version 4.2 with Bootstrap v2.3.2
Files in my app's assets folder:
bootstrap-responsive.css
bootstrap.css
test.html
No need to add "android.permission.INTERNET" in Android manifest since css files are available locally within the app's asset folder.
Here's a screenshot of how it is rendered. There is no reason why you could not see it unless there are issues with the CSS files (which is again unlikely since you can see the results on browser).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With