2011.09.01(5)——— android checkbox自定义样式
参考:[url]http://gundumw100.iteye.com/blog/1025176[/url]
[size=large]drawable/checkbox.xml[/size]
[size=large]values/styles.xml[/size]
layout.xml
参考:[url]http://gundumw100.iteye.com/blog/1025176[/url]
[size=large]drawable/checkbox.xml[/size]
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/checkbox_checked" /><!--选中时效果 -->
<item android:state_checked="false" android:drawable="@drawable/checkbox_unchecked" /><!--未选中时效果 -->
</selector>
[size=large]values/styles.xml[/size]
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@layout/checkbox_selector</item>
<item name="android:paddingLeft">25.0dip</item>
<item name="android:maxHeight">10.0dip</item>
</style>
</resources>
layout.xml
<CheckBox android:layout_marginLeft="15dp"
android:layout_marginRight="20dp" android:layout_marginTop="3dp"
android:layout_marginBottom="0dp" android:id="@+id/setting_amrbitrate_low"
android:checked="false" android:layout_width="40dp"
android:layout_height="22dp" android:text="" android:textColor="#000000"
style="@style/MyCheckBox" android:textStyle="bold"
android:layout_alignParentRight="true" />