【oschina android源码分析】切换夜间模式的实现
来源:互联网 发布:2016年癌症数据 权威 编辑:程序博客网 时间:2024/06/09 08:00
点击夜间模式按钮监听方法
private void switchTheme() { if (AppContext.getNightModeSwitch()) { AppContext.setNightModeSwitch(false); } else { AppContext.setNightModeSwitch(true); } if (AppContext.getNightModeSwitch()) { getActivity().setTheme(R.style.AppBaseTheme_Night); } else { getActivity().setTheme(R.style.AppBaseTheme_Light); } getActivity().recreate(); }
说明:
1. 页面模式的配置在本地要保存。AppContext.setNightModeSwitch(false);
2. 调用setTheme方法。系统写两套主题:AppBaseTheme_Light和AppBaseTheme_Night。
3. 调用getActivity().recreate()。
更具体的原理解释请见:
http://www.kymjs.com/code/2015/05/26/01
http://echo.vars.me/android/android-night-mode/
0 0
- 【oschina android源码分析】切换夜间模式的实现
- Android 切换夜间模式的简单实现
- Android 夜间模式的切换
- Android夜间模式的切换
- Android实现日夜间模式切换
- Android主题切换实现夜间模式
- 实现夜间模式切换
- 夜间模式的切换的实现方式
- 在android中,夜间模式的切换
- Android夜间模式切换的方法
- android夜间模式的实现
- Android夜间模式的实现
- android 夜间模式的实现
- Android 夜间模式的实现
- android夜间模式的实现
- android夜间模式的实现
- 夜间模式的切换
- 夜间模式的切换
- MongoDB服务无法启动,发生服务特定错误:100
- 详解Android动画之Frame Animation
- BZOJ 4554: [Tjoi2016&Heoi2016]游戏
- 【oschina android源码分析】页面通知(站内信)的设计-android轮询方案
- Android 编程下的 TraceView 简介及其案例实战
- 【oschina android源码分析】切换夜间模式的实现
- 韦东山虚拟机中arm-Linux-gcc的安装方法
- vector容器与iterator迭代器
- Android数据过滤器:Filter
- mybaits中文官方文档地址
- 红黑树右旋转
- 程序员练级之路 (作者:陈皓)
- Android 多个Edittext不为空,Button才可点击的方法
- 【oschina android源码分析】下载更新新版本的设计