android - Webview adding white space on right side -
how load html content fixed height , width android webview has height , width set wrap_content? html page i.e label.html loading assets.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>untitled document</title> <style> @charset "utf-8"; /* css document */ .main{ width:50%; height:200px; border: 1px solid #09ed1c; float:left; background-color:#00f3ff; } h1{ color:#fc1d21; } </style> </head> <body> <div class="main" align="center"> <h1>this page created using internal css</h1> </div> </body> </html> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/blue"> <webview android:id="@+id/wv_help" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </relativelayout> websettings websettings = mwebviewhelp.getsettings(); websettings.setjavascriptenabled(true); mwebviewhelp.setscrollbarstyle(webview.scrollbars_inside_overlay); mwebviewhelp.loadurl("file:///android_asset/label.html");
this adding white space on right side of webview though wrap_content,webview.scrollbars_inside_overlay not solving issue,any appreciated.
you need add in html header:
<meta name="viewport" content="width=device-width, initial-scale=1">
so this:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>[your_document_name]</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head>
i hope works not please respond
wiki
Comments
Post a Comment