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

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

问题描述

我正在使用 PhoneGap 开发应用程序.我无法在 webview 中启用内置放大/缩小.

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类是

And The Activity class is

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"
/> 

推荐答案

检查您是否没有包裹您的 Webview 的 ScrollView.

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 之外,然后使用同一行:

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天全站免登陆