一、RadioButton / CheckBox  

  系统自带的RadioButton/CheckBox的样式,注定满足不了实际运用中的情况,有时候自定义自己的样式;此次把自己中工作学习过程中所学到的东西总结如下:

  先看效果图:

    <RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:drawableRight="@drawable/rb_background"
android:text="AAA" /> <RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:checked="true"
android:drawableRight="@drawable/rb_background"
android:text="BBB" />
rb_background.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg2" android:state_checked="true" android:state_enabled="true"></item>
<item android:drawable="@drawable/bg1" android:state_checked="false"></item>
</selector>

都比较简单,换作CheckBox也是一样的道理,不再举例;
  另:在使用RadioGroup的时候,居然突然想不起来怎么获取当选前择的是哪一项,经过查证,通过RadioGroup.OnCheckedChangeListener接口即可获取选择项改变事件回调捕获选项id;

        group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
}
});

二、ProgressBar
  1、使用图片实现滚动效果.原始图像

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/image_progress"
android:pivotX="50%"
android:pivotY="50%" > </rotate>

    <ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/my_progress" />

  2、自定义ProgressBar颜色

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" > <shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false" >
<gradient
android:centerColor="#FFFFFF"
android:centerY="0.50"
android:endColor="#FFFF00"
android:startColor="#000000"
android:type="sweep" //
android:useLevel="false" />
</shape> </rotate>

  3、自定义horizontal进度条

  自定义ProgressBar横向样式进度条需要配置一个layer-list,其中包括3个item分别是background,secondaryProgress,progress分别用于表示ProgressBar的背景,次要进度(如:表示播放器缓冲的进度),进度的样式;

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" /> <gradient
android:angle="270"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:startColor="#ff9d9e9d" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" /> <gradient
android:angle="270"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:startColor="#80ffd300" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" /> <gradient
android:angle="270"
android:endColor="#AEEEEE"
android:startColor="#FF3030" />
</shape>
</clip>
</item> </layer-list>
    <ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="10dip"
android:progress="20"
android:max="100"
android:progressDrawable="@drawable/pb_background"/>

未完待续...

Android 常用控件自定义样式RadioButton、CheckBox、ProgressBar、的更多相关文章

  1. [转]easyui常用控件及样式API中文收藏

    [转]easyui常用控件及样式收藏 2013-05-06 23:01 30612人阅读 评论(0) 收藏 举报  分类: java ee(5)  目录(?)[+] CSS类定义: div easyu ...

  2. android 控件自定义样式

    一.按钮(Button) 方式1.存在.9图片或图片时   可在drawable文件夹下新建xml文件style_button_one.xml,代码如下 <?xml version=" ...

  3. 常用的基本控件 android常用控件

    1.TextView:(文本框):不能编辑    android:textColor="@color/tv_show_color" 字体颜色    android:textSize ...

  4. Android常用控件及对应Robotium API

    最近发现Android控件不熟悉,看Robotium的API都费劲. 常用Android控件: 控件类型 描述 相关类 Button 按钮,可以被用户按下或点击,以执行⼀个动作 Button Text ...

  5. WPF自定义控件与样式(5)-Calendar/DatePicker日期控件自定义样式及扩展

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: 日历控 ...

  6. Android中的常用控件之进度条(ProgressBar)

    ProgressBar的常用属性:style,进度条的样式,默认为圆形,用style="?android:attr/progressBarStyleHorizontal"可以将进度 ...

  7. silverlight 控件自定义样式 实现方法

    1:在app.xaml中加入需实现的样式,如: <Application.Resources> <Style x:Key="NodeStyle" TargetTy ...

  8. Android常用控件之GridView使用BaseAdapter

    我们可以为GridView添加自定义的Adapter,首先看下用自定义Adapter的显示效果 在布局文件main.xml文件中定义一个GridView控件 <RelativeLayout xm ...

  9. 【转】WPF自定义控件与样式(5)-Calendar/DatePicker日期控件自定义样式及扩展

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等. 本文主要内容: 日历控件Calendar自定义样式: 日期控件DatePicker自定 ...

随机推荐

  1. rsync同步的艺术

    转自:http://roclinux.cn/?p=2643 如果你是一位运维工程师,你很可能会面对几十台.几百台甚至上千台服务器,除了批量操作外,环境同步.数据同步也是必不可少的技能. 说到“同步”, ...

  2. JavaWeb项目生成PDF文件添加水印图片并导出

    一.前言 首先需要在Maven中添加相应的jar包依赖,若项目没用到Maven,也可自行下载相应所需的jar包(itextpdf.jar 与 itext-asian.jar),如下图所示.点此下载 M ...

  3. Selenium自动化测试第一天(下)

    如有任何学习问题,可以添加作者微信:lockingfree 目录 Selenium自动化测试基础 Selenium自动化测试第一天(上) Selenium自动化测试第一天(下) Selenium自动化 ...

  4. 运用GamePlayKit的GKEntity及GKComponent 的iOS游戏开发实例

    GameplayKit是一个面向对象的框架,为构建游戏提供基础工具和技术. GameplayKit包含用于设计具有功能性,可重用架构的游戏的工具,以及用于构建和增强诸如角色移动和对手行为的游戏玩法特征 ...

  5. Siki_Unity_2-10_数据结构与算法

    Unity 2-10 数据结构与算法 任务1-1:数据结构简介 数据结构:数据存储的结构,数据之间的关系 数据结构分类: 集合:同属于一个集合 线性结构:数据元素存在一对一的关系 树形结构:数据元素存 ...

  6. python爬虫基础之一(爬淘宝)

    没想到python如此强大, 今天看一会视频学会了一段python爬虫 这就是我今天学到的内容爬去淘宝网关于书包的一些信息,包括价格, #coding=utf-8 import requests#导入 ...

  7. 搭建hexo博客并部署到github上

    hexo是由Node.js驱动的一款快速.简单且功能强大的博客框架,支持多线程,数百篇文章只需几秒即可生成.支持markdown编写文章,可以方便的生成静态网页托管在github上. 感觉不错. 前端 ...

  8. 数数字 (Digit Counting,ACM/ICPC Dannang 2007 ,UVa1225)

    题目描述:算法竞赛入门经典习题3-3 #include <stdio.h> #include <string.h> int main(int argc, char *argv[ ...

  9. 1208: [HNOI2004]宠物收养所

    1208: [HNOI2004]宠物收养所 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 12030 Solved: 4916 Description ...

  10. Leetcode - 461. Hamming Distance n&=(n-1) (C++)

    1. 题目链接:https://leetcode.com/problems/hamming-distance/description/ 2.思路 常规做法做完看到评论区一个非常有意思的做法.用了n&a ...