android spin / continuously rotate an image untill I command it to stop

耗尽温柔 提交于 2019-12-11 19:54:10

问题


I want to make a little fresh icon.

When I click on it, I want it to spin like a progress dialog, until my refresh is completed, then it must stop spinning.

How can I achieve this?

I tried with an animation like so:

RotateAnimation rotateAnimation = new RotateAnimation(30, 90,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);                
            refreshBtn.startAnimation(rotateAnimation);

but that only rotates once or twice and then stops.


回答1:


Try this:

RotateAnimation rotateAnimation = new RotateAnimation(30, 90,
                        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setRepeatCount(Animation.INFINITE);
rotateAnimation.setRepeatMode(Animation.RESTART);
refreshBtn.startAnimation(rotateAnimation);


来源:https://stackoverflow.com/questions/22380941/android-spin-continuously-rotate-an-image-untill-i-command-it-to-stop

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