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_ANIMATIONflag 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);
相关文章推荐
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load.
- How to Answer(From Stack OverFlow)
- When to use LinkedList and When to use ArrayList- An answer in StackOverFlow
- zz from stackoverflow - effecient tip: how switch tabs in Eclipse
- How to bind a GridView to a list of multiple types? NHibernate proxy causing problems with databinding [From stack overflow]
- Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load
- How do you copy the contents of an array to a std::vector in C++ without looping? (From stack over flow)
- Android Activity – From One Screen To Another Screen从一个屏幕切换到另一屏幕,Intent
- Stack Overflow requires external JavaScript from another domain,which is blocked or failed to load
- Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load.
- How do I size a UITextView to its content? from stack overflow!
- How to get file path in onActivityResult in Android 4.4
- How to remove native support from an Android Project in eclipse because eclipse is showing errors in
- How to import class from other package when building android image
- how to invoke activity when app in background
- How to play videos in android from assets folder or raw folder?
- Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load.
- How to detect when the mouse move away from a TPanel in Delphi ?