【发布时间】:2020-04-30 10:06:26
【问题描述】:
在这个项目中,我尝试制作一个动画闪屏,它会在进入主活动之前出现,但在我执行之后,闪屏不会出现,而是直接进入主活动。 如何解决这个问题?
这是我的飞溅活动课
private ImageView container;
private AnimationDrawable animationDrawable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash)
container = findViewById(R.id.iv_icons);
container.setBackgroundResource(R.drawable.mysplash_animation);
animationDrawable = (AnimationDrawable) container.getBackground();
}
@Override
protected void onResume() {
super.onResume();
animationDrawable.start();
checkAnimationStatus(50, animationDrawable);
}
private void checkAnimationStatus(final int time, final AnimationDrawable animationDrawable) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (animationDrawable.getCurrent() != animationDrawable.getFrame(animationDrawable.getNumberOfFrames() - 1))
checkAnimationStatus(time, animationDrawable);
else finish();
}
}, time);
}
}
这是我的 manifest.xml
<application
android:allowBackup="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity android:name=".SplashActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
【问题讨论】:
-
时间变量的值是多少?
-
能否详细说明您的问题
-
您的启动活动未设置为默认启动器,所以是的,它不会显示
标签: android xml android-studio android-layout splash-screen