android 如何更改应用程序的启动动画?

eqoofvh9  于 2023-05-05  发布在  Android
关注(0)|答案(2)|浏览(140)

是否有任何方法可以通过编程方式更改应用程序启动动画?每当我启动一个应用程序时,它的动画就像它来自屏幕底部,但我希望它来自屏幕顶部。
任何帮助都很感激。

55ooxyrt

55ooxyrt1#

您可以简单地使用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);
lstz6jyr

lstz6jyr2#

你可以试试这个

top_down.xml在anim文件夹中

<?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在anim文件夹中

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

相关问题