Android 动画速度太慢
我正在使用具有无限重复设置的动画监听器,重要的是每次循环时都会调用 onAnimationRepeat 函数。
当动画持续时间设置为 ~100 毫秒或更长时,这一切都可以很好地工作。我设置的任何较小的值(例如 30ms)似乎仍然在 100ms 左右。我在设备和模拟器上尝试过这个。
我正在使用 Alphaanimation,但我也尝试了其他类型的 Android 动画。
有没有办法让任何动画在持续时间设置为 50 毫秒左右甚至更快的情况下正常工作?
I am using an animationlistener with INFINITE repeat settings and it is important that every time it loops the onAnimationRepeat function is called.
This all works well with the animattion duration set to ~100ms or higher. Any smaller value I set (e.g. 30ms) still seems to be around 100ms. I tried this on device and on emulator.
I am using an Alphaanimation but i also tried other types of android animations.
Is there a way to make any animation work properly with a duration set around 50ms and faster?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与其他“滑动”动画相比,AlphaAnimation 是一种相当资源密集型的动画。
您可以尝试使用 TraceView 进行调查,以准确了解挂起的位置。
我怀疑这只是动画的开销导致一切变慢。
尝试一下 TraceView,报告结果,我看看是否可以提供进一步的建议。
希望这有帮助!
AlphaAnimation is a fairly resource-intensive animation compared to other "sliding" animations.
You may try investigating with TraceView to see exactly where it is getting hung up.
I suspect that it is simply the overhead of the animation that is slowing everything down.
Give the TraceView a shot, report back with results and I'll see if I can give further advice.
Hope this helps!
我知道这已经很旧了,但对于像我现在这样四处搜索的人来说。
尝试将其添加到动画 xml 中:
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
如果我错了,请纠正我,但我认为它适用于 Translate 和 Alpha
示例:
I know this is old, but for people googling around like I am now.
Try adding this into the animation xml:
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
Correct me if I'm wrong but i think it works for both Translate and Alpha
Example: