【问题标题】:How to Change the launch animation of an Application?如何更改应用程序的启动动画?
【发布时间】:2018-01-11 15:38:45
【问题描述】:

有没有办法以编程方式更改应用程序启动动画? 每当我启动一个应用程序时,它的动画就像它来自屏幕底部一样,但我希望它来自屏幕顶部。

感谢任何帮助。

【问题讨论】:

  • 启动动画由手机的Launcher应用决定。你不能也不应该控制它。用户将在他们的手机上安装客户启动器应用程序,您不应试图控制它。

标签: java android android-animation launching-application programmatically


【解决方案1】:

您可以简单地使用 AlphaAnimation ,然后在 onCreate() 方法中将其应用到 Activity 的布局中:

super.onCreate(savedInstace);
this.setContentView(R.layout.main);
RelativeLayout layout = findViewById(R.id.idLayout);
AlphaAnimation animation = new AlphaAnimation(0.0f , 1.0f ) ;
animation.setFillAfter(true);
animation.setDuration(1200);
//apply the animation ( fade In  or whatever you want) to your LAyout
layout.startAnimation(animation);

【讨论】:

    【解决方案2】:

    你可以试试这个

    top_down.xml在动画文件夹中

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
     <translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="5000"/>
     <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="5000" />
    </set>
    

    down_top.xml在动画文件夹中

     <?xml version="1.0" encoding="utf-8"?>
        <set xmlns:android="http://schemas.android.com/apk/res/android">
         <translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="5000" />
         <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="5000" />
     </set>
    

    并应用于此。

    Intent intent = new Intent(this, SomeActivity.class);
    startActivity(intent);
    overridePendingTransition(R.anim.top_down, R.anim.down_top);
    

    【讨论】:

    • 这将有助于在应用程序中从一个活动切换到另一个活动。我想在启动应用程序时更改动画。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-12
    • 1970-01-01
    相关资源
    最近更新 更多