【发布时间】:2017-01-23 21:04:39
【问题描述】:
我们尝试通过 google cloud print 打印 webview 内容,但无论我们做什么,结果打印输出都会增加一些边距。
有没有办法去掉这个边距? 我们试过了:
<body style="margin: 0; padding: 0">
然后
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
然后
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
都没有用...
【问题讨论】:
-
我不知道它是否会影响打印,但
html{margin:0; padding:0;}可以创造奇迹。 -
这可能看起来很愚蠢,但是您是否也尝试过在样式属性中使用
!important?在根节点上也一样,html,即html, body{ margin: 0 !important; padding:0 !important; }?为了以防万一,总是可以将border设置为 0。或者,也许在你的 CSS 中试试这个:@page{ margin-left: 0px; margin-right: 0px; margin-top: 0px; margin-bottom: 0px; } -
我们都试过了,似乎边距与 html 无关,而是 webview 在尝试打印时添加的恒定边距
标签: android html webview android-webview google-cloud-print