在values下的文件夹新建一个color.xml 在values-night下的文件夹新建一个color.xml values下的文件夹里的:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ir4s_radio_bg_u_dark">#1AFFFFFF</color>
<color name="ir4s_radio_bg_u">#1A000000</color>
</resources>
values-night下的:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ir4s_radio_bg_u">#1AFFFFFF</color>
</resources>
新建一个ir4s_radio_bg_s_light_2.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#00D062" android:state_checked="true" android:state_enabled="true" />
<item android:alpha="0.5" android:color="#00D062" android:state_checked="true" android:state_enabled="false" />
<item android:color="@color/ir4s_radio_bg_u" android:state_checked="false" android:state_enabled="true" />
<item android:alpha="0.5" android:color="#1A000000" android:state_checked="false" android:state_enabled="false" />
</selector>
在ir4s_checkbox_2.xml里引用
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2011 The Android Open Source ProjectLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/ir4s_checkbox_checked"/>
<item android:drawable="@drawable/ir4s_checkbox_unchecked_2"/>
</selector>
在style里引用ir4s_checkbox_2
<style name="Ir4sItemViewSelectStyle" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/ir4s_checkbox_2</item>
</style>
最后在页面的xml里的CheckBox里引用这个样式,示例:
<CheckBox
android:id="@+id/ck_child_checked"
style="@style/Ir4sItemViewSelectStyle"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_alignParentStart="true"
android:layout_centerVertical="true" />
|