WebView onScalechanged Min&最大限度
我已经在项目中实现了一个WebView,需要显示PDF。我启用了捏缩放毫无问题的缩放,也有两个按钮可以控制Zoom in&放大。我需要禁用它们的“缩放”将达到最大值和最小值。
目前,我正在使用canzoomin
& canzoomout
onscalechanged
侦听器中的方法,它有效,但是如果您在AndroidDevelopers官员中阅读,则不会对其进行重新计算。
由于种族条件,这种方法容易出现在 Web渲染和UI线程;更喜欢WebViewClient#onScaLechanged。
我的问题是:我如何知道何时在没有canzoomin
&的情况下达到最小值和最大值。 canzoomout
?
override fun onScaleChanged(view: WebView?, oldScale: Float, newScale: Float) {
super.onScaleChanged(view, oldScale, newScale)
bottomBarView.setEnabledItem(view!!.canZoomIn(),ENBottomBarItem.zoomIn)
bottomBarView.setEnabledItem(view.canZoomOut(),ENBottomBarItem.zoomOut)
}
I have implemented a webview in my project, where I need to show a pdf. I enabled pinch to zoom without any problem, i also have two button to control zoom in & zoom out. I need to disable their if "scaling" will reach maximum and minimum.
At this moment i'm using canZoomIn
& canZoomOut
method in OnScaleChanged
listener and it works but if you read in androidDevelopers official their doesn't reccomend it.
https://developer.android.com/reference/android/webkit/WebView#canZoomIn()
This method is prone to inaccuracy due to race conditions between the
web rendering and UI threads; prefer WebViewClient#onScaleChanged.
My question is: How can i know when user reach min and max without canZoomIn
& canZoomOut
?
override fun onScaleChanged(view: WebView?, oldScale: Float, newScale: Float) {
super.onScaleChanged(view, oldScale, newScale)
bottomBarView.setEnabledItem(view!!.canZoomIn(),ENBottomBarItem.zoomIn)
bottomBarView.setEnabledItem(view.canZoomOut(),ENBottomBarItem.zoomOut)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论