一、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. 四、新时间日期API

    一.使用 LocalDate .LocalTime .LocalDateTime LocalDate.LocalTime.LocalDateTime 类的实例是不可变的对象,分别表示使用 ISO-86 ...

  2. Http接口系列:如何提高Http接口用例的数据稳定性

    此文已由作者王婷英授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 为了尽可能多的释放手工测试,提高测试效率,我们都会想到使用自动化测试,如http接口自动化测试.doubbo ...

  3. 微信小程序学习笔记(1)- 按钮触发的函数的定义以及不同页面之间的数据传递

    <view class='item' bindtap='onCountryTab' data-idx='4'> 1)bindtap属性用来设置控件需要绑定的函数,函数用单引号括起来:. 2 ...

  4. Arduino-元件简介

    DS18B20温度传感器 DS18B20是DALLAS公司生产的一种常用的温度传感器,其具有体积小巧.硬件功耗低.抗干扰能力强.精准度高的特点.该传感器具有单总线通讯的能力,电压范围为3.0V~5.5 ...

  5. 一种新的自动化 UI 测试解决方案 Airtest Project

    今天分享一个自动化UI测试工具airtest——一款网易出品的基于图像识别面向游UI测试的工具,也支持原生Android App基于元素识别的UI自动化测试.主要包含了三部分:Airtest IDE. ...

  6. adb获取设备的序列号

    用数据线连接手机, 打开开发者模式, 并赋予相关权限, 在CMD命令行输入: adb devices 第一个参数即为设备的序列号, 第二个参数device表示设备的状态是在线.

  7. leetcode-组合总数III(回溯)

    组合总和 III 找出所有相加之和为 n 的 k 个数的组合.组合中只允许含有 1 - 9 的正整数,并且每种组合中不存在重复的数字. 说明: 所有数字都是正整数. 解集不能包含重复的组合.  示例 ...

  8. MySQL数据库怎么截取字符串?

    函数: 1.从左开始截取字符串 left(str, length) 说明:left(被截取字段,截取长度) 例:select left(content,200) as abstract from my ...

  9. C++ ifndef /define/ endif 作用和用法

    ifndef/define/endif”主要目的是防止头文件的重复包含和编译 比如你有两个C文件,这两个C文件都include了同一个头文件.而编译时,这两个C文件要一同编译成一个可运行文件,于是问题 ...

  10. Python3 Tkinter-Grid

    1.创建 from tkinter import * root=Tk() lb1=Label(root,text='Hello') lb2=Label(root,text='Grid') lb1.gr ...