我怎样才能得到一个web视图当前的规模​​(机器人) [英] How can i get the current scale of a webView(android)

查看:172
本文介绍了我怎样才能得到一个web视图当前的规模​​(机器人)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

中的getScale()是pcated在API级别17所以去$ P $,我怎样才能得到一个web视图当前的规模​​。 我试图覆盖的方法onScaleChanged,但那倒被称为除非我改变的规模...

解决方案

我知道这个问题是有点老了,但是这可能会帮助一个人(比如我),尤其是如果有人想覆盖的WebView,并添加onTouch监听器,来检测的WebView内容结束。

您可以使用:

  getResources()。getDisplayMetrics()。密度
 

而不是

  webView.getScale()
 

这是德precated。

这是相同的值,即重新presents屏幕像素密度,相比 MDPI 值。 因此,这将是如下:

  • LDPI:0.75
  • MDPI:1.0
  • 华电国际:1.5
  • xhdpi:2.0
  • xxhdpi:3.0
  • xxxhdpi:4.0

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...

解决方案

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

这篇关于我怎样才能得到一个web视图当前的规模​​(机器人)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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