在WebView Android中启用缩放选项 [英] Enable Zoom Option In WebView Android

查看:170
本文介绍了在WebView Android中启用缩放选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PhoneGap开发应用程序。我无法在网络视图中启用内置的放大/缩小。

I am developing the application using PhoneGap. I cannot enable built in zoom in/out in the webview.

我使用onCreate函数中的以下代码

I used Following code in onCreate Function

WebView web = (WebView) findViewById(R.id.webview);
web.getSettings().setBuiltInZoomControls(true);

但它不起作用。

而活动类为

activity_main.xml

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/> 


推荐答案

检查您是否没有

Check if you don't have a ScrollView wrapping your Webview.

看来ScrollView会阻碍手势。

It seems ScrollView gets in the way of the pinch gesture.

>要修复它,只需把您的WebView外面的ScrollView nd然后使用相同的行:

To fix it, just take your Webview outside the ScrollView nd then use the same line:

webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);

这篇关于在WebView Android中启用缩放选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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