我在我的应用程序中有 webview,我将动态获取该 webview 的数据,我正在控制该视图的放大。当我得到这个网址http://content.vaayoo.com/AppsPlatForm/DealsaheadWeb/m_facebooks.aspx?Token=moc.liamg@liahs时,会出现放大控制。但是当我得到以下网址 https://maps.google.com/?saddr=12.9302,77.5831&daddr=12.928464,77.584258时,没有出现缩放控制。问题出在哪里?任何形式的帮助都非常感谢..下面是我的代码..
protected void applyStyles() {
// applying the zooming property to webview.
final FrameLayout.LayoutParams ZOOM_PARAMS = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP);
View zoom = ((WebView) view).getZoomControls();
FrameLayout ContentView = (FrameLayout) ((Activity) context)
.getWindow().getDecorView().findViewById(android.R.id.content);
ContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.VISIBLE);
}
下面是我正在为 webview 进行所有设置的代码。
if (data != null && webview != null) {
String webData = data.toString();
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
webview.getSettings().setUseWideViewPort(false);
//webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSupportZoom(true);
webview.requestFocus(View.FOCUS_DOWN);
webview.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_UP:
if (!v.hasFocus()) {
v.requestFocus();
}
break;
}
return false;
}
});
System.out.println("webdata" + webData);
if (webData.startsWith("http")) {
webview.loadUrl(webData);
} else {
webview.loadData(webData, "text/html", "utf-8");
}
}
提前致谢