开发者

set the animation to the activity without xml file

Hi I want to set the animation to an activity开发者_如何学Go without xml file.Please give me some suggestions on this topic.Thanks in advance


AnimationSet myAnimation = new AnimationSet(true);
// Create a translate animation
/* TranslateAnimation animation=new TranslateAnimation(0,0,237,0);
animation.setDuration(250);
// Add each animation to the set
myAnimation.addAnimation(animation);*/
ScaleAnimation scale = new ScaleAnimation((float)0.5, (float)1, (float)0.5, (float)1);
scale.setFillAfter(true);
scale.setDuration(500);
<activity name>.startAnimation(scale);


private Animation createAnimation() {
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(1000);
    animation.setInterpolator(new AccelerateDecelerateInterpolator());
    return animation;
}

Simple alpha animation, the way to create others is pretty much the same.

Use view.startAnimation(yourAnimation) to start animation, and yourAnimation.reset() before reusing the same animation again.

P.S. Maybe I misunderstood you, and you want an animation between activity changes?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜