替换 android Launcher 活动动画

发布于 2024-12-12 01:21:40 字数 623 浏览 0 评论 0原文

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

我的目标是:

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

提前致谢!

I'm creating my own Android Launcher.

The problem is:

  • When I launch an activity, it slides left...
  • When I close it, it slides right...
  • This is annoying and ugly!

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:

  • Also remove the close application animation.
  • Or change the launch/close default animations.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

趁年轻赶紧闹 2024-12-19 01:21:41

其实我也认为这是一个令人恼火的动画,所以我也想改变它......我发现它是-它是默认动画......检查这个链接...... .....http://developer.android.com/reference/android/view/animation/GridLayoutAnimationController.html
所以我停止寻找这个问题......

Actually I also think it is a irritating animation,so i also wanted to change it........and i found it as- it is default animation.........check this link........http://developer.android.com/reference/android/view/animation/GridLayoutAnimationController.html
so i stopped searching for this issue ....

乜一 2024-12-19 01:21:40

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

如果您还想在关闭 Activity 时设置动画,例如当用户按下后退或主页按钮,您应该将 overridePendingTransition() 添加到 onPause() 方法。
如果您想在其他应用程序启动您的 Activity 时设置动画,请在 super.onCreate() 之前添加 overridePendingTransition()。

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

你的笑 2024-12-19 01:21:40

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文