Android WebView 缩放错误
缩放后(通过触摸执行)WebView 似乎无法正常工作。 要在页面加载缩放页面后重现,但不允许在缩放后滚动视图(这将导致问题不出现)。单击链接。链接突出显示,就像单击一样,但 WebView 不会导航到下一页(因此在视觉上它仍保留在相同的 url 上)。 以下是测试项目源和apk 来重现此内容。
在 Nexus S 和 HTC Wildfire S 上复制。 我将不胜感激任何想法或指示。
package com.test;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class TestWebViewBugActivity extends Activity {
WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.setWebViewClient(new WebViewClient() {
});
webView.loadUrl("http://google.com/");
}
}
聚苯乙烯 根据评论的建议更改了源和apk中的布局XML(高度现在是静态值)
WebView does not seem to work properly after zoom (performed with touch).
To reproduce after page load zoom page but do not allow view to be scrolled after zoom (it will cause the issue not to appear). Click on link. Link highlighted like it is clicked but WebView not navigate to the next page (so visually it remains on same url).
Here are test project source and apk to reproduce this.
Reproduced on Nexus S and HTC wildfire S.
I'll appreciate any thoughts or directions.
package com.test;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class TestWebViewBugActivity extends Activity {
WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.setWebViewClient(new WebViewClient() {
});
webView.loadUrl("http://google.com/");
}
}
P.S.
Layout XML in sources and apk changed according to suggestions from comments (height is now static value)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您需要修复 Main.xml 文件。 WebView 中的布局高度是“fill_parent”。当客户端放大时,WebView 也会放大,影响父级。这是您的 Main.XML
尝试为 WebView 指定一个定义的高度。然后尝试缩放 inn 看看会发生什么。
I believe you need to fix your Main.xml file. The layout height in your WebView is "fill_parent". When the client zooms inn the WebView enlarges impacting the parent. This is your Main.XML
Try giving the WebView a defined height. Then try zooming inn and see what happens.
在布局 main.xml
在活动中
它应该可以工作。
尝试其他页面而不是 google.com。在我的手机上打开默认浏览器。但我的私人页面运行良好:)
In layout main.xml
In activity
And It should work.
Instead of google.com try other pages. On my phone opens default browser. But my private page works fine :)