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>
相关推荐
王二蛋与他的张大花12 分钟前
反编译后只剩 2 个类:一次自研 DEX 壳加固的完整复盘
android·安全·逆向
StarsGreen6 小时前
Android 12 中的“域“与“权限“介绍
android
咖啡色格调7 小时前
项目已托管在 Gitee,如何同时推送到 GitHub
gitee·github
恋猫de小郭8 小时前
Android Keep Rules 解读,直接影响 Google Play 上架和曝光
android·前端·flutter
FlightYe8 小时前
音视频修炼之容器与协议(六):HTTP 协议
android·linux·网络·网络协议·算法·http·音视频
StarsGreen1 天前
Android中的seccomp相关信息介绍
android
阿杰m1 天前
Android源码第二十四章:OTA 与 APEX——重启后换了什么?
android
用户081268037411 天前
差点格式化一台 Redmi K80:一次 WebView 翻车的无损救援实录
android·debug·webview
阿杰m1 天前
Android源码第二十五章:WebView 与 Chromium——网页何时画上屏?
android·android studio
StarsGreen1 天前
Android中特殊文件的相关说明
android