Method
- 用”android:drawableLeft“取代”android:background”来设置CheckBox的自定义样式;同时自身设置”android:text”来显示文字提示,取代CheckBox+TextView的模式
- 使用TouchDelegate,>引用[link text](“http://stackoverflow.com/questions/1343222/is-there-an-example-of-how-to-use-a-touchdelegate-in-android-to-increase-the-siz“)
Method 1 具体代码:
styles.xml<style name="check_box_orange"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:button">@null</item> <item name="android:drawableLeft">@drawable/selector_check_box_orange</item> <item name="android:drawablePadding">10dp</item> <!--optional--> <item name="android:singleLine">true</item> <item name="android:layout_marginLeft">15dp</item> <item name="android:textColor">@color/text_color_gray</item> <item name="android:textSize">@dimen/middle_text_size_14</item> </style>
drawable selector 三种图片的状态
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/ic_checkbox_disable" android:state_enabled="false"></item> <item android:drawable="@drawable/ic_checkbox_checked" android:state_checked="true"></item> <item android:drawable="@drawable/ic_checkbox_normal"></item> </selector>