日夜切换(动画效果会被重置)


val configuration = resources.configuration
            configuration.uiMode = configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
            delegate.localNightMode = when (configuration.uiMode) {
                Configuration.UI_MODE_NIGHT_YES -> AppCompatDelegate.MODE_NIGHT_NO
                Configuration.UI_MODE_NIGHT_NO -> AppCompatDelegate.MODE_NIGHT_YES
                else -> {
                    AppCompatDelegate.MODE_NIGHT_YES
                }
            }
            recreate()

你可能感兴趣的:(开发语言,kotlin,android,android,studio)