6

I'm creating new launcher for myself. now when I run applications from my main activity it has this default animation which put my launcher behind and pops new application on top of it. Instead of this, I want to attach my own animation. Preferably I want to default material animation revealing from touch point.

Things I have tried so far:

You need to use a Theme.AppCompat theme (or descendant) with this activity on Android

http://tips.androidhive.info/2015/09/android-how-to-apply-material-design-theme/

 <style name="swLaunch" parent="swLaunch.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/explode</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/explode</item>
    <item name="android:windowEnterAnimation">@android:transition/explode</item>
    <item name="android:windowExitAnimation">@android:transition/explode</item>
    <item name="android:taskToFrontEnterAnimation">@android:transition/explode</item>
    <item name="android:taskToBackEnterAnimation">@android:transition/explode</item>
    <item name="android:taskToFrontExitAnimation">@android:transition/explode</item>
    <item name="android:taskToBackExitAnimation">@android:transition/explode</item>
    <item name="android:inAnimation">@android:transition/explode</item>
    <item name="android:layoutAnimation">@android:transition/explode</item>
    <item name="android:windowShowAnimation">@android:transition/explode</item>
    <item name="android:activityOpenEnterAnimation">@android:transition/explode</item>
    <item name="android:fragmentOpenEnterAnimation">@android:transition/explode</item>
</style>

this is how I launch my applications:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.gm");
if (launchIntent != null) {
    startActivity(launchIntent);
}
Dave Thomas
  • 3,667
  • 2
  • 33
  • 41
CBeTJlu4ok
  • 1,072
  • 4
  • 18
  • 51
  • Why down voted my answer ? you have asked question and you have given answer. i think it is point game you are playing here. – Wasim K. Memon Nov 15 '16 at 09:40

1 Answers1

5

To animate starting an activity:

int left = 0, top = 0;
int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
ActivityOptions opts = ActivityOptions.makeClipRevealAnimation(v, left, top, width, height);
startActivity(i, opts.toBundle());

where i is an Intent and v is a View

to animate going back to home screen (either by pressing Home button or Back button)

@Override
public void onResume() {
    super.onResume();
    // override default transition animation
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
CBeTJlu4ok
  • 1,072
  • 4
  • 18
  • 51