android 如何改变checkbox样式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android 如何改变checkbox样式相关的知识,希望对你有一定的参考价值。
参考技术A 1、首先res/drawable中定义编写如下样式:<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/check_true" android:state_checked="true"></item>
<item android:drawable="@drawable/check_true" android:state_selected="true"></item>
<item android:drawable="@drawable/check_true" android:state_pressed="true"></item>
<item android:drawable="@drawable/check_false"></item>
</selector>
2、在layout中添加checkbox控件
<CheckBox
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_check"
android:button="@null"
android:checked="true"/>
其中drwable/btn_check为1中顶一个文件名称,另外必须将android:button设置为@null。
@drawable/check_true和@drawable/check_false为checkbox不同状态的图片,可自行设计。 参考技术B 写了XML文件 自定义啦本回答被提问者采纳
checkbox选中改变默认样式,改变颜色,一般用背景图
###checkbox选中改变默认样式,改变颜色,一般用背景图
.cconte div input[type='checkbox']{
position: absolute;
left:-0.2rem;
top: .1rem;
-webkit-appearance: none;
appearance:none;//去掉复选框的默认背景样式
-moz-appearance:none;
display: block;
width: .16rem;
height: .16rem;
border:1px solid #B5B5B5;
outline: none;
border-radius: 2px;
}
.cconte div input[type='checkbox']:checked{
background: url(/crm/images/icon/866.png) no-repeat center /cover;
border:none;
}
<div class="cconte cconte0 disflexcoum flexstart">
<div class="">
<input type="checkbox" checked="checked" name="brand0hs" value="1">
</div>
</div>
以上是关于android 如何改变checkbox样式的主要内容,如果未能解决你的问题,请参考以下文章