admin 管理员组文章数量: 1184232
1.创建valuse-night文件夹,设置夜间模式的color
2.修改夜间模式下的主题的样式为:Theme.AppCompat.DayNight.NoActionBar
3.点击控件切换日渐夜间模式
if(SPUtils.get(this, SPKey.NIGHT,false)as Boolean){
SPUtils.put(this, SPKey.NIGHT,false)// delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_NO// recreate()
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)}else{
SPUtils.put(this, SPKey.NIGHT,true)// delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_YES// recreate()
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)}4.在基类BaseActivity中给其他页面设置模式进行生效
@OverrideprotectedvoidonResume(){super.onResume();
Boolean isNight =(Boolean) SPUtils.get(this, SPKey.NIGHT,false);if(isNight){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);}else{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);}}版权声明:本文标题:玩转屏幕亮度:夜间模式与SWF、Flash中心的魅力发现 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1771300142a3543034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论