实例1-自定义风格

html
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="horizontal"
tools:ignore="Suspicious0dp">
<CheckBox
android:id="@+id/channel_1"
style="@style/test3_dialogtree_checkbox"
android:text="通道1"/>
<CheckBox
android:id="@+id/channel_2"
style="@style/test3_dialogtree_checkbox"
android:text="通道2" />
<CheckBox
android:id="@+id/channel_3"
style="@style/test3_dialogtree_checkbox"
android:text="通道3" />
<CheckBox
android:id="@+id/channel_4"
style="@style/test3_dialogtree_checkbox"
android:text="通道4" />
<CheckBox
android:id="@+id/channel_5"
style="@style/test3_dialogtree_checkbox"
android:text="通道5" />
<CheckBox
style="@style/test3_dialogtree_checkbox"
android:text="通道6" />
</LinearLayout>
html
<style name="test3_dialogtree_checkbox">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:textSize">20sp</item>
<item name="android:padding">12dp</item>
<item name="android:minHeight">50dp</item> <!-- 最小高度 -->
<item name="android:minWidth">50dp</item> <!-- 最小宽度 -->
<item name="android:button">@drawable/custom_checkbox_large</item> <!-- 自定义复选框 -->
</style>
drawable中custom_checkbox_large.xml

html
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 选中状态 -->
<item android:state_checked="true">
<shape android:shape="rectangle">
<stroke android:width="3dp" android:color="#2196F3" />
<solid android:color="#2196F3" />
<size android:width="25dp" android:height="25dp" /> <!-- 放大到 40x40 -->
</shape>
</item>
<!-- 未选中状态 -->
<item>
<shape android:shape="rectangle">
<stroke android:width="2dp" android:color="#666666" />
<size android:width="25dp" android:height="25dp" /> <!-- 放大到 40x40 -->
</shape>
</item>
</selector>