Tuesday, 13 August 2013

android webview 100% width and html margins/paddings

android webview 100% width and html margins/paddings

i have some problem with content in webview
Simple webview:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<WebView
android:id="@+id/someWebview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
/>
</RelativeLayout>
Here i call that
WebView webView = (WebView)view.findViewById(R.id.someWebview);
webView.clearView();
webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.loadDataWithBaseURL(null, content, null, "utf-8", null);
and content looks something like this
<!DOCTYPE html>
<html>
<head>
<title>some title</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width; initial-scale=1.0;
maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;"/>
<style type="text/css">
*{margin:0; padding:0;}
html, body{width:100%;}
</style>
</head>
<body>
<p style="width: 90%; margin: 100px 0 0 100px;>asdasdasdasd</p>
</body>
</html>
So, problem is what width=90% and margin-left does not work, but
margin-top is ok.. how can i fix this? I can't use android:paddingLeft
cause i need margin only some content not all of this

No comments:

Post a Comment