android webview css margin-left/right 不起作用

Lit*_*ggy 5 android webview

我对 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>
Run Code Online (Sandbox Code Playgroud)

我在这里称之为

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);
Run Code Online (Sandbox Code Playgroud)

和内容看起来像这样

<!DOCTYPE html>
<html>
<head>
  <title>some</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>
    *{margin:0; padding:0;}
    html, body{width:100%;}
  </style>
</head>



<body>
  <p style="width:50%; margin: 50px 0 0 100px; background-color: #0000ff">asdasd</p>
  <div style="width: 20%; margin-left: 50px; background-color:#ff0000; padding:0 50px;"><p style="background-color:#ffffff;">dfgdfg</p><div style="width:30%;margin-left: 50px;background-color:#1e1e1e;">dsdsd</div></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

所以,问题是 margin-left 不起作用,但 margin-top 没问题..我该如何解决这个问题?我不能使用 android:paddingLeft 因为我只需要一些内容而不是全部内容

我无法添加要发布的图片,因此将它们上传到此处:http : //imgur.com/FObDiaA,q9W5tvV 第一个是桌面浏览器,第二个是 webview

更新

因此,我想我通过解析 html 并在我需要的地方添加带有填充的容器 div 来“解决”问题,但这是一个糟糕的 hack 并且猜测并非所有情况都可以使用它,所以我认为问题仍然存在 - 为什么留有边距/对不对?