3 回答

TA貢獻1893條經驗 獲得超10個贊
經過一些研究,我發現這是不可能的。當我們想要在加載主要功能時顯示某些內容時使用啟動屏幕,因此我們將要顯示的可繪制對象包含在清單中,以便在我們的主要活動加載時快速顯示。這個啟動屏幕,就像它在 Manifest 中一樣,出現在其他任何東西之前,所以如果我們可以動態地改變啟動屏幕的主題,我們將在加載其他所有內容時失去快速出現。

TA貢獻1805條經驗 獲得超9個贊
public void onCreate(Bundle savedInstanceState) {
if (Constants.dayMode){
setTheme(android.R.style.yourTheme);
} else {
setTheme(android.R.style.yourTheme);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.actvity);
}

TA貢獻1829條經驗 獲得超6個贊
試試這個代碼
主題.xml
<resources>
<style name="AppThemeLight" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
</style>
<style name="AppThemeDark" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
</style>
<!-- This will set the fade in animation on all your activities by default -->
<style name="WindowAnimationTransition">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
活動
@Override
protected void onCreate(Bundle savedInstanceState) {
AppSettings settings = AppSettings.getInstance(this);
setTheme(settings.getBoolean(AppSettings.Key.USE_DARK_THEME) ? R.style.AppThemeDark : R.style.AppThemeLight);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transition_theme);
//
}
添加回答
舉報