您的位置:首页 > 移动开发 > Android开发

How to provide animation when calling another activity in Android?( from Stack overflow)

2010-11-10 13:37 525 查看
I have two Activities A and B. I want to have the shrink Animation when Activity A calls B and maximize animation when Activity B calls A. I don't need the animation xml files for this.When we call another Activity in Android it gives its default animation and then it calls shrink animation.What I want is that the default animation should not occur and the animation that I want should occur.Can we actually give the animation when calling another Activity?Hope to get a quick response.RegardsAnswer 1You can prevent the default animation (Slide in from the right) with the
Intent.FLAG_ACTIVITY_NO_ANIMATION
flag in your intent.
i.e.:
Intent myIntent = new Intent(context, MyActivity.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
context.startActivity(myIntent);
[/code]then in your Activity you simply have to specify your own animation.Answer2(This is better)use OverridePendingTransition method to achieve it. which is in the Activity class. Sample Animations in the apidemos example's res/anim folder. check it. more than check the demo inIntent intent = new Intent();intent.setComponent(new ComponentName("com.jason.recite", ProjectInfoActivity.class.getName()));startActivity(intent);ProjectActivity.this.overridePendingTransition(R.anim.fade, R.anim.hold);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐