ANDROID笔记:自定义CheckBox样式

主界面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未选中状态的图片.

更多相关文章

  1. Android的标题栏(状态栏)
  2. android 禁用屏蔽系统状态栏(statusbar) 转
  3. 【Android自学笔记】Android获取手机和存储卡上的图片
  4. android中去掉标题栏和状态栏,实现全屏
  5. android中如何显示图片的一部分
  6. android > layout > background 背景图片重复
  7. 如何在EditText中设置固定图片——Android移动开发

随机推荐

  1. android 嵌套ViewPager + Fragment实现仿
  2. Android(安卓)热修复(腾讯bugly)
  3. Java/Android倒计时(开始,暂停,恢复,停止)
  4. android的socket程序中conn.getResponseC
  5. Android4.0 input touch解析
  6. Android手机拍照
  7. Android周学习Step By Step(7)--Activity简
  8. Android(安卓)NDK: WARNING: APP_PLATFOR
  9. Android中的GPS应用开发入门教程
  10. Android(安卓)平台上长连接的实现