TranslateAnimation之后的坐标错误

时间:2017-04-19 10:05:46

标签: java android animation webview android-animation

我的设备的分辨率为1080*960,我的网页浏览量为from y=0 to y=960

我在WebView上使用TranslateAnimation将其翻译为TranslateAnimation animation = new TranslateAnimation(0f, 0f, 0f, 960f); animation.setDuration(300); animation.setFillAfter(true); webview.startAnimation(animation);

y range [960, 1920]

Android帮助我将webview绘制到y = 960,但我无法触发y range [0, 960]中的任何触摸事件,相反,我的触摸事件是在JSONObject中触发的。

似乎某些控件组件或其他内容未通过webview转换为y = 960.

是否有任何方法可以将控件转换为y = 960,或推荐其他更好的解决方案?

非常感谢。

1 个答案:

答案 0 :(得分:2)

TranslateAnimation为矩阵设置动画,而不是View本身。所以,你最终会看到一种幻觉:你看到View实际上有其他坐标。

您需要在动画结束后更改WebView坐标,或者您可以使用流畅的API代替TranslateAnimation

webview.animate()
       .y(960f)
       .setDuration(300);
相关问题