標籤:android style blog http color 使用 io strong
1.首先在drawable檔案夾中添加drawable檔案checkbox_style.xml。
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:drawable="@drawable/checkbox_pressed" android:state_checked="true"/>
- <item android:drawable="@drawable/checkbox_normal" android:state_checked="false"/>
- <item android:drawable="@drawable/checkbox_normal"/>
-
- </selector>
2.在values檔案夾下的styles.xml檔案中添加CustomCheckboxTheme樣式。
[html] view plaincopy
- <style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
- <item name="android:button">@drawable/checkbox_style</item>
- </style>
3.在布局檔案中使用CustomCheckboxTheme樣式。
[html] view plaincopy
- <CheckBox
- android:id="@+id/select_all"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/CustomCheckboxTheme" />
使用到的圖片資源
checkbox_normal.png
checkbox_pressed.png