How can i get the current scale of a webView(android)

Deadly 提交于 2019-12-10 17:14:51

问题


getScale () was deprecated in API level 17. so , how can i get the current scale of a webview. i tried to override the method onScaleChanged, but it won`t be called unless i change the scale...


回答1:


I know this question is a bit old, but this may help someone (like me), especially if someone wants to override WebView and add onTouch listener, to detect WebView's content end.

You can use:

getResources().getDisplayMetrics().density

instead of

webView.getScale()

which is deprecated.

It is the same value, that represents screen density, compared to mdpi value. So, it will be as follows:

  • ldpi: 0.75
  • mdpi: 1.0
  • hdpi: 1.5
  • xhdpi: 2.0
  • xxhdpi: 3.0
  • xxxhdpi: 4.0



回答2:


WebView.getScaleX() and WebView.getScaleY() might help, is this what you want?

I don't have enough reputation to comment on your questions, so I'll just give an answer. Hope this helps (:



来源:https://stackoverflow.com/questions/19897751/how-can-i-get-the-current-scale-of-a-webviewandroid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!