如何停止的Andr​​oid的WebView内容挖掘回流时双? [英] How to stop android webview content reflow when double tapped?

查看:238
本文介绍了如何停止的Andr​​oid的WebView内容挖掘回流时双?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想的WebView可以滚动,但它需要表现得就像一张照片,这样滚动不会导致的WebView重新安排其布局以适应屏幕。它应该只是提供滚动页面时真的比屏幕大。

First of all, I would like the WebView can be scrolled but it need to behave just like a picture such that the scrolling would not cause the WebView to rearrange its layout to fit screen. It should just provide scrollbar when the page is really bigger than screen.

我读<一个href=\"http://stackoverflow.com/questions/12103402/how-to-stop-android-webview-from-wrapping-content-while-zooming\">How从包装内容,而缩放?停止Android的web视图。它的工作原理除了执行双击。

I have read How to stop android webview from wrapping content while zooming?. It works except the double tap performed.

要重新生成问题,结果
1.我打开一个网页,是全文的WebView全屏的。结果
2.双击屏幕的右侧。 &LT; - 在这里它只是放大的,没有问题结果
3.双击屏幕的左侧。

To regenerate the problem,
1. I load a web page which is full of text to fullscreen WebView.
2. double tap the right side of screen. <--here it just zoom in, no problem
3. double tap the left side of screen.

问题来了。该文本是重新排列。当我放大到原来的规模。该文本只需填写半个屏幕。

The problem come. The text is rearranged. When I zoom back to original scale. The text is just fill in half of the screen.

如何阻止web视图来不管发生了什么重新安排它的布局?

How to stop webView to rearrange its layout no matter what is happening?

推荐答案

我终于通过此行解决这一点。

I finally solve of this by this line.

webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);

默认情况下, WebSettings.LayoutAlgorithm NARROW_COLUMNS

通过研究 android.webkit.ZoomManager 类,它必须回流(重新)如果 NARROW_COLUMNS 及其他如果有必要的情况是回流。我不知道什么是必要的是但至少它不会在我的情况了回流。

By study the android.webkit.ZoomManager class, it must reflow (rearrange) if NARROW_COLUMNS and the else case is reflow if necessary. I don't know what the "necessary" is but as least it won't reflow anymore in my case.

有一些题外话,但我的目标是prevent内容的回流。我发现在Android 2.x版本的设备,有时,网页内容会如果我点击即使设置 webView.getSettings()的zoomControl,用于按钮回流setUseWideViewPort(真); 。对的Andr​​oid 4时,不存在这个问题。

There is some off-topic but my goal is to prevent content reflow. I found out that on Android 2.x device, sometime, the web page content would reflow if I click the zoomControl button even though set webView.getSettings().setUseWideViewPort(true);.On Android 4, this problem is not exist.

如果我没有记错。我认为它是网页meta标签的原因这一点。因此,我要确保网页没有​​这个行:&LT; META NAME =视口CONTENT =WIDTH =设备宽度&GT; 。而我真的能看到不同的,如果没有这条线,网页内容不回流。

If I am not mistaken. I think it is the web page meta tag cause this. Therefore, I make sure the web page don't have this line:<meta name="viewport" content="width=device-width"> .And I really can see the different that without this line, the web content do not reflow.

这篇关于如何停止的Andr​​oid的WebView内容挖掘回流时双?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆