TranslateAnimation 后坐标错误
Wrong coordinates after TranslateAnimation
我的设备分辨率是1080*1920 (portrait)
,我的webview大小是1080*960
我在 WebView 上使用 TranslateAnimation 来翻译它 from y=0 to y=960
。
TranslateAnimation animation = new TranslateAnimation(0f, 0f, 0f, 960f);
animation.setDuration(300);
animation.setFillAfter(true);
webview.startAnimation(animation);
Android 帮我把 webview 画到 y=960,但是我在 y range [960, 1920]
不能触发任何触摸事件,而是在 y range [0, 960]
触发了我的触摸事件.
似乎有些控制组件或其他东西没有被 webview 翻译成 y=960。
是否有任何方法可以将控件也转换为 y=960,或者推荐其他更好的解决方案?
非常感谢。
TranslateAnimation
动画矩阵,而不是 View
本身。所以,你最终会看到一个错觉:你看到一个 View
实际上有其他坐标。
要么你需要在动画结束后改变WebView
坐标,要么你可以使用流畅的API代替TranslateAnimation
:
webview.animate()
.y(960f)
.setDuration(300);
我的设备分辨率是1080*1920 (portrait)
,我的webview大小是1080*960
我在 WebView 上使用 TranslateAnimation 来翻译它 from y=0 to y=960
。
TranslateAnimation animation = new TranslateAnimation(0f, 0f, 0f, 960f);
animation.setDuration(300);
animation.setFillAfter(true);
webview.startAnimation(animation);
Android 帮我把 webview 画到 y=960,但是我在 y range [960, 1920]
不能触发任何触摸事件,而是在 y range [0, 960]
触发了我的触摸事件.
似乎有些控制组件或其他东西没有被 webview 翻译成 y=960。
是否有任何方法可以将控件也转换为 y=960,或者推荐其他更好的解决方案?
非常感谢。
TranslateAnimation
动画矩阵,而不是 View
本身。所以,你最终会看到一个错觉:你看到一个 View
实际上有其他坐标。
要么你需要在动画结束后改变WebView
坐标,要么你可以使用流畅的API代替TranslateAnimation
:
webview.animate()
.y(960f)
.setDuration(300);