I'm creating my own Android Launcher.
The problem is:
I've alread been able to remove the launch animation with:
Intent launch_intent = new Intent("android.intent.action.MAIN");
launch_intent.addCategory("android.intent.category.LAUNCHER");
launch_intent.setComponent(new ComponentName(packageName, name));
launch_intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
activity.startActivity(launch_intent);
My objective is to:
Thanks in advance!
Launcher Activities are the activities that can be launched for a given intent. For example, when you press an app icon on the home screen, the StartActivity intent starts the activity you have specified as the launcher activity.
Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.
I had a look at the Android API demos, As was suggested you should use the "overridePendingTransition()" method, it sets the animation of the incoming activity and the animation of the outgoing activity.
The method shoud be added afer startActivity() or after finish():
Intent launch_intent = new Intent("android.intent.action.MAIN");
launch_intent.addCategory("android.intent.category.LAUNCHER");
launch_intent.setComponent(new ComponentName(packageName, name));
activity.startActivity(launch_intent);
overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
The transitions are standard android animations, for example the zoom_enter will be something like that:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="2.0" android:toXScale="1.0"
android:fromYScale="2.0" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
If you also want to set an animation when your activity is being closed, for example when user presses the back or home button, you should add the overridePendingTransition() to the onPause() method.
If you want to set an animation when your activity is being launched by some other application, add the overridePendingTransition() before the super.onCreate().
For displaying standard launcher animation you have to apply a specific theme for your main launcher activity. This theme should be (or should be inherited from) android:Theme.Wallpaper.
android:theme="@android:style/Theme.Wallpaper"
For such theme Android Framework provides specific animations that you may see for standard Launcher.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With