android-控件-多选框CheckBox

实例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>
相关推荐
geovindu9 小时前
sql:Search-Optimized SQL Queries using mysql 9.0
android·数据库·sql·mysql·数据库开发·数据库架构
知之则吱吱10 小时前
Android 开发者验证机制迎来新变化:核心要求、实施时间与开发者应对指南
android·google
墨天梦12 小时前
D09_Retrofit接口与数据转换
android·kotlin·retrofit
电商API_1800790524713 小时前
闲鱼商品列表API接口商品详情API接口请求示例(含一份真实响应数据示例)
android·数据挖掘·网络爬虫·跨境电商·反向海淘
我命由我1234513 小时前
Android 广播 - 组件通信
android·java·开发语言·android studio·android jetpack·android-studio·android runtime
阿俊-全栈开发13 小时前
LikeShop 单商户标准版商品管理二开:分类、SKU 规格与库存联动实现
android·likeshop·likeshop开源商城
用户21816970493016 小时前
Kotlin 语法二
android
妖星16 小时前
android 源码分析surfaceFinger是如何通过设置属性启动bootanim
android
JoyMonitor16 小时前
APK mmap 内存增长定位:pagemap 与 DEX 结构联合定位方法
android