手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android开发教程之自定义控件checkbox的样式示例
android开发教程之自定义控件checkbox的样式示例
摘要:主界面xml文件复制代码代码如下:/res/drawable-hdpi/check_selector.xml复制代码代码如下:P.S:重点:...

主界面xml文件

复制代码 代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<CheckBox

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:button="@drawable/check_selector"

android:checked="true" />

</RelativeLayout>

/res/drawable-hdpi/check_selector.xml

复制代码 代码如下:

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/checkok" android:state_checked="true"></item>

<item android:drawable="@drawable/checkno" android:state_checked="false"></item>

</selector>

P.S:重点: android:button="@drawable/check_selector"

check_selector.xml中的checkok为CheckBox选中状态的图片,checkno为CheckBox未选中状态的图片.

【android开发教程之自定义控件checkbox的样式示例】相关文章:

Android开发笔记之:如何安全中止一个自定义线程Thread的方法

Android开发笔记之:AsyncTask的应用详解

Android开发笔记之:Splash的实现详解

在android开发中进行数据存储与访问的多种方式介绍

Android开发之动画实现方法

Android开发笔记之:消息循环与Looper的详解

android开发中finish()和System.exit(0)的区别

Android开发之多个Activity间的交互

Android开发之选项组件

Android实现自定义带文字和图片Button的方法

精品推荐
分类导航