In android, why will my button animation only clear from onClick()?

∥☆過路亽.° 提交于 2019-12-13 03:36:56

问题


I wanted to animate a button, so I used this answer:

https://stackoverflow.com/a/4852468/559525

and got it animating on the first attempt. But then when I tried to stop the animation from various places in my application, I found that it will ONLY stop the animation if I call view.clearAnimation() from inside the onClick() callback.

My first guess is this has to do with multi threading synchronize issues, but I know about the UI thread and I was pretty sure I was calling the clearAnimation() method from approved places in the main UI thread.

My other thought was that the UI needed to be invalidated or refreshed? But I tried putting this call right before doing an invalidate on my main layout and that didn't help. I know my invalidate is working properly because it works to update other button attributes like color.

Thanks for any advice!

来源:https://stackoverflow.com/questions/11109657/in-android-why-will-my-button-animation-only-clear-from-onclick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!