开发者

Apply Two Animations to the Same View?

I applied an entry animation to one of my ImageButton (fade_in.xml which is in the project anim/ folder). Now, after a button click, I want to apply an exit animation (fade_out.xml which is in the same folder)

When I do that, the entry animation happens. However, the exit one do NOT !! It seems that each View will accept ONLY one animation.

Is this true? How can I work around this problem?

-

-

UPDATE:

This is in the onCreate() method for setting the entry animation:

Animation fade = AnimationUtils.loadAnimation(this, R.anim.fade_in);
fade.setStartOffset(600);
img.startAnimation(fade);
img.setvisibility(View.VISIBLE);

And this is in the onClick() method for some button b1:

Animation fade2 = 开发者_StackOverflow中文版AnimationUtils.loadAnimation(this, R.anim.fade_out);
fade.setStartOffset(500);
img.startAnimation(fade2);
img.setvisibility(View.INVISIBLE);


You can use ViewFlipper with getInAnimation and getOutAnimation methods.
Other solution is setting animation in your code(as far I understand you set animation in xml file).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜