How get webview scale in Android 4

若如初见. 提交于 2019-12-05 03:45:10

I'm developing for API level 17 and I ended up using the deprecated method getScale() for the same reason. WebViewClient.onScaleChanged() simply wasn't triggered when I changed the scale using pinch zoom in the WebView. I have a custom GestureListener in my extended WebView that behaves differently when the view is zoomed in (scale 1.0+). I couldn't reliably get the proper scale value when I set a class variable in onScaleChanged().

try :

public MyWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    setWebViewClient(new WebViewClient() {
        @Override
        public void onScaleChanged(WebView view, float oldScale, float newScale) {
            super.onScaleChanged(view, oldScale, newScale);
            currentScale = newScale;
        }
    });
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!