- 浏览: 20615 次
文章分类
最新评论
<?xml version="1.0" encoding="utf-8">
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/focused"/>
<item android:state_checked="false" android:state_pressed="true"
android:drawable="@drawable/normal"/>
<item android:state_checked="false" android:drawable="@drawable/normal"/>
<item android:state_checked="true" android:drawable="@drawable/focused"/>
</selector>
state_checked选中状态state_pressed按下状态
即分别设置checkbox选中和没选中时按下和没按下时显示的图片。
应用到checkbox与button不同,并不是设置background属性,而是设置style属性,
所以我们要写一个style。
strings.xml写一个style.
<style name="MyCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox</item>
应用到checkbox:
<CheckBox android:layout_width="wrap_content"
android:layout_height="wrap_content" style="@style/MyCheckBox"/>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/focused"/>
<item android:state_checked="false" android:state_pressed="true"
android:drawable="@drawable/normal"/>
<item android:state_checked="false" android:drawable="@drawable/normal"/>
<item android:state_checked="true" android:drawable="@drawable/focused"/>
</selector>
state_checked选中状态state_pressed按下状态
即分别设置checkbox选中和没选中时按下和没按下时显示的图片。
应用到checkbox与button不同,并不是设置background属性,而是设置style属性,
所以我们要写一个style。
strings.xml写一个style.
<style name="MyCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox</item>
应用到checkbox:
<CheckBox android:layout_width="wrap_content"
android:layout_height="wrap_content" style="@style/MyCheckBox"/>
发表评论
-
android startActivityForResult
2012-12-25 09:02 529Bashboard.java Intent i = new I ... -
android 实现左右滑动指引效果
2012-12-18 17:29 642见附录源码 ViewPager 的使用 -
android listview 点击listview下面 显示更多
2012-12-18 15:05 1249见附件源码. 看一遍就懂了,很简单的例子. -
android listview 上拉刷新
2012-12-18 13:45 739具体源码见,附件下载。 这里列出关键性思路: 1.先定义一个 ... -
android post get
2012-12-18 09:46 691//post HttpClient client=new De ... -
android listview
2012-12-17 17:32 0android:drawSelectorOnTop=" ... -
android 实用方法
2012-12-17 15:28 0URLUtil.isValidUrl(String blogU ... -
android 分隔线
2012-12-17 15:27 867android 分隔线 1.用View 配置文件 <V ... -
android textview
2012-12-17 11:25 618textview 标题style设置. <style ... -
android edittext 边框 源码实现
2012-12-17 10:34 1207android经典edittext选中样式是,黄色,不选中是灰 ... -
android 布局边框
2012-12-17 09:25 793<RelativeLayout androi ... -
android 返回键 事件
2012-12-17 08:58 765//startActivityForResult()情况的In ... -
android 文字描边
2012-12-14 17:17 1931文字描边 android:shadowColor=" ... -
android 渐变背景
2012-12-14 15:43 1252<?xml version="1.0" ... -
android button 自定义
2012-12-14 14:58 631wp_button.xml(\drawable目录下建个) ... -
android application
2012-12-14 14:03 569android 开发中共享全局 ... -
android windowSoftInputMode
2012-12-14 11:42 530android:windowSoftInputMode属性 & ... -
android 屏幕
2012-12-07 10:33 660术语和概念 Screen size(屏幕尺寸) 指手机实际的物 ... -
android 绑定 service
2012-11-29 10:39 1662(1) 一个Activity和一个Service绑定在一起,一 ... -
android 国际化 屏幕适配 样式和主题
2012-11-23 15:19 1262(1)国际化 values文件夹:如果没找到语言环境对应的默认 ...
相关推荐
Android自定义checkbox的代码
自定义仿腾讯checkbox。包含点击、聚焦等个各种操作,都会显示出不同的状态图片。
如何自定义CheckBox的样式 1:首先在布局文件中添加CheckBox的控件配置,如: <CheckBox android:id="@+id/button1" style="@style/CheckBoxStyles"//这里就是用户可以自定CheckBox的样式 android:layout_width...
简单实现自定义checkbox控件四种选择状态的图片样式
本文通过实例代码演示如何在Android中如何自定义CheckBox,实现的效果很好,有需要的可以参考借鉴。
这是一个关于自定义checkbox、RadioButton, Switch, SwitchPreference , CheckPreference 等控件颜色的 demo。 让控件显示我们想要的颜色,同时又不影响使用Android5.0提供的动画,何乐而不为。
主要介绍了Android中自定义Checkbox控件实例,本文使用两张图片来美化Checkbox组件,需要的朋友可以参考下
Android自定义RadioButton和CheckBox样式,重写RadioButton的onDraw()方法,实现颜色选择器效果。
一个简单实现自定义带CheckBox的ListView。
本demo实现功能为:Expandablelistview子项checkBox先获取已选择状态,在次过程中可修改子项选择,最终提交选择子类的项,并打印相关数据
Android开发中自定义CheckBox
项目中需要有个Dialog全选对话框,点击全选全部选中,取消全选全部取消。下午查了些资料,重写了一下Dialog对话框。把代码放出来。
主要介绍了android自定义checkbox的样式示例,需要的朋友可以参考下
大家是不是对系统自带的CheckBox产生乏味感了呢?今天这篇文章给大家带来的是一款全新的CheckBox,下面来一起看看下面的CheckBox吧!有需要的朋友们可以参考借鉴。
Android 自定义横向滚动条。当你的横向字段或者表格很多时候,显示不下内容,可以使用很想滚动条进行滚动。竖向方面我添加了listview进行添加数据。两者滚动互不干扰。长按listview的item出现checkbox,可以进行多选...
一个简单的拥有丰富自定义内容的CheckBox多选框集成Gradlecompile 'com.bigmercu.cBox:cbox:1.08'Mavenallprojects { repositories { jcenter() maven { url '...
最近抽了点时间,针对android一些控件的样式做了完整自定义,主要包括Spinner的样式完全自定义、RadioButton[CheckBox样式雷同]样式完全自定义、Rating样式自定义,代码已经经过测试,有需要的可以下载