当使用 FLAG_ACTIVITY_NEW_TASK 和 FLAG_ACTIVITY_CLEAR_TASK 设置 Intent 时,应用程序暂时变白
App Turns White Temporaryly when Intent is set with FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK
Intent intent = new Intent(LoginActivity.this, Profile.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
我在登录后使用此标志清除所有 activity 堆栈。问题是,由于屏幕瞬间变白,过渡变得非常难看。有什么解决方法可以避免这种情况吗?
P.S.: 两个活动的背景都是红色。我想知道白色是从哪里来的。
在您的应用主题中添加以下行,禁用 windows 片段前预览或 activity 加载。(白屏问题)
<item name="android:windowDisablePreview">true</item>
见here
在您的 styles.xml
文件中添加这一行:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowDisablePreview">true</item>
...
</style>
它将禁用新加载屏幕(又名 white/black 屏幕)的预览模式。
如果您想在加载新屏幕之前使用自定义背景,请考虑添加以下行:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">@drawable/slash_screen</item>
...
</style>
Intent intent = new Intent(LoginActivity.this, Profile.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
我在登录后使用此标志清除所有 activity 堆栈。问题是,由于屏幕瞬间变白,过渡变得非常难看。有什么解决方法可以避免这种情况吗?
P.S.: 两个活动的背景都是红色。我想知道白色是从哪里来的。
在您的应用主题中添加以下行,禁用 windows 片段前预览或 activity 加载。(白屏问题)
<item name="android:windowDisablePreview">true</item>
见here
在您的 styles.xml
文件中添加这一行:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowDisablePreview">true</item>
...
</style>
它将禁用新加载屏幕(又名 white/black 屏幕)的预览模式。
如果您想在加载新屏幕之前使用自定义背景,请考虑添加以下行:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">@drawable/slash_screen</item>
...
</style>