首页 > 其他 > 详细

夜间模式的切换

时间:2016-03-23 13:10:19      阅读:148      评论:0      收藏:0      [点我收藏+]

//黑夜白天模式切换的配置
attrs
<resources>

    <attr name="bjcolor" format="reference|color"></attr>
    <attr name="txcolor" format="reference|color"></attr>

</resources>

style
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="fault" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="@attr/bjcolor"> @android:color/white</item>
        <item name="@attr/txcolor">@android:color/black</item>
    </style>

    <style name="Night" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="@attr/bjcolor">@android:color/darker_gray</item>
        <item name="@attr/txcolor">@android:color/white</item>
    </style>

</resources>

//代码的是实现
if (blFlag) {
            this.setTheme(R.style.Night);
            blFlag = false;
            editor.putBoolean("b", false);
        } else {
            this.setTheme(R.style.fault);
            blFlag = true;
            editor.putBoolean("b", true);
        }


夜间模式的切换

原文:http://www.cnblogs.com/weiyangge/p/5310574.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!