簡體   English   中英

替換android Launcher活動動畫

[英]Replace android Launcher activity animations

我正在創建自己的Android啟動器。

問題是:

  • 當我發起一項活動時,它向左滑動......
  • 當我關閉它時,它向右滑動......
  • 這很煩人也很難看!

我已經能夠通過以下方式刪除啟動動畫:

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

我的目標是:

  • 同時刪除關閉的應用程序動畫。
  • 或者更改啟動/關閉默認動畫。

提前致謝!

我看了一下Android API演示,正如建議您應該使用“overridePendingTransition()”方法,它設置傳入活動的動畫和傳出活動的動畫。
該方法應在startActivity()或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);

轉換是標准的Android動畫,例如zoom_enter將是這樣的:

<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>

如果您還想在活動關閉時設置動畫,例如當用戶按下后退或主頁按鈕時,您應該將overridePendingTransition()添加到onPause()方法。
如果要在某些其他應用程序啟動活動時設置動畫,請在super.onCreate()之前添加overridePendingTransition()。

其實我也認為這是一個令人生氣的動畫,所以我也想改變它........我發現它是 - 它是默認動畫.........檢查這個鏈接... ..... http://developer.android.com/reference/android/view/animation/GridLayoutAnimationController.html所以我停止搜索這個問題....

要顯示標准啟動器動畫,您必須為主啟動器活動應用特定主題。 這個主題應該是(或者應該繼承)android:Theme.Wallpaper。 android:theme="@android:style/Theme.Wallpaper"

對於此類主題,Android Framework提供了您可能會在標准Launcher中看到的特定動畫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM