2016-11-02 2 views
6

Ich erstelle neue Launcher für mich. Wenn ich jetzt Anwendungen von meiner Hauptaktivität aus starte, hat diese Standardanimation meinen Launcher zurück und gibt eine neue Anwendung darüber aus. Stattdessen möchte ich meine eigene Animation anhängen. Vorzugsweise möchte ich die Materialanimation, die vom Berührungspunkt aufdeckt, als Standard festlegen.Android Animation beim Ausführen neuer Anwendung

Dinge, die ich bisher versucht:

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> 

das ist, wie ich meine Anwendungen starten:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.gm"); 
if (launchIntent != null) { 
    startActivity(launchIntent); 
} 
+0

Warum nach unten gestimmt geht zurück auf Home-Bildschirm zu animieren meine Antwort ? Sie haben eine Frage gestellt und Sie haben eine Antwort gegeben. Ich denke, es ist ein Punktspiel, das du hier spielst. – androidnoobdev

Antwort

5

Starten einer Aktivität zu animieren:

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()); 

wo i eine Intent und v ist ein Ansicht

(entweder durch Drücken Home-Taste oder Zurück-Taste)

@Override 
public void onResume() { 
    super.onResume(); 
    // override default transition animation 
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); 
} 
Verwandte Themen