5

我正在创建自己的 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);

我的目标是:

  • 同时删除关闭应用程序动画。
  • 或更改启动/关闭默认动画。

提前致谢!

4

3 回答 3

6

我查看了 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()。

于 2011-10-25T19:40:33.703 回答
1

要显示标准启动器动画,您必须为您的主启动器活动应用特定主题。这个主题应该是(或应该继承自)android:Theme.Wallpaper。 android:theme="@android:style/Theme.Wallpaper"

对于此类主题,Android 框架提供了您可能会在标准 Launcher 中看到的特定动画。

于 2012-02-03T04:50:47.733 回答
0

其实我也觉得这是一个刺激的动画,所以我也想改变它........我发现它是-它是默认动画............检查这个链接...... .....http://developer.android.com/reference/android/view/animation/GridLayoutAnimationController.html 所以我停止搜索这个问题......

于 2012-01-02T08:52:45.577 回答