开发者

Frame by frame button animation

I have added a frame by frame animation for a button background. When the button is pressed, the animation is started, and when it's finished, another activity is start开发者_开发知识库ed. The animation is simulating drawing a circle on the button, and the first frame is transparent.

The problem is that when I'm coming back to the first activity, the button will have the last animation frame as the background (the whole circle). I tried to set a transparent frame as the last frame from the list. But in this case, the circle will disappear before the next activity is launched.

Is there an easy way to have the last frame before launching the next activity, and then, when the user get back to the first activity, to have the animation at the first frame?


In the activities onResume() method find the button by ID and then reset the button's background to the animation, or try the clearAnimation() method of the button (I assume this sets the animation back to 0 rather than removing it?). Something like:

@Override
public void onResume() {
 super.onResume();
 Button mButton = (Button) findViewById(R.id.android_button);
 // Clear anitmation
 mButton.getAnimation().reset();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜