因此,我有一个简单的应用程序可以在 WebView 中加载图像板。在除 ICS 之外的大多数 Android 版本上,一切看起来都很棒。首先,呈现的页面不再填充父级,而是填充大约 80% 的视口(viewport)。其次,页面上帖子的图像和文本被包裹在窄列中,占视口(viewport)宽度的大约 45%。
我意识到这可能是 4.0+ 如何读取此 wakaba 图像板 (xhtml) 的元素的问题,但我在调查时遇到了困难。也许有人可以解释 ICS webviews 发生了什么变化以帮助我隔离问题?这是 webkit 的问题吗?
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
来源:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
wv = new WebView(this);
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setMinimumFontSize(48);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
setContentView(R.layout.main );
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
wv.loadUrl("http://example.com");
wv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
wv.setScrollbarFadingEnabled(true);
}
被压缩的 html 帖子示例:
<span class="filesize">File: <a target="_blank" href="/b-/src/1329696064044.png">1329696064044.png</a> -(<em>1063442 B, 1433x1080</em>)</span> <span class="thumbnailmsg">Thumbnail displayed, click image for full size.</span><br />
<a target="_blank" href="/b-/src/1329696064044.png"> <img src="/b-/thumb/1329696064044s.jpg" width="500" height="376" alt="1063442" class="thumb" /></a> <a name="2058"></a>
<label><input type="checkbox" name="delete" value="2058" /> <span class="filetitle"></span> <span class="postername">Anonymous</span> 02/19 17:01</label> <span class="reflink">
<a href="/b-/res/2058.html#i2058">No.2058</a> </span> [<a href="/b-/res/2058.html">Reply</a>] <blockquote> <p>I'm not saying he's real, but he's real.<br />
<a href="http://www.youtube.com/watch?v=rkJZYxWAhUA&feature=related" rel="nofollow">http://www.youtube.com/watch?v=rkJZYxWAhUA&feature=related</a></p> </blockquote> <br clear="left" /><hr />
先发制人的感谢!
最佳答案
我在 ICS Webview 上也得到了这个,这似乎是非常不可预测的。
导致我的窄宽度问题的原因似乎是同时具有 setUseWideViewPort(true)
和 setUseWideViewPort(true)
。所以只有其中之一,看看它是否能解决问题。
关于android - 窄宽度的 ICS 渲染 webview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9374078/