Android圆环形颜色选择器:HoloColorPicker

HoloColorPicker实现圆环形颜色选择器,可以改变颜色饱和度来选择颜色。选择颜色时,可以用手指沿着圆环滑动一个滑块,从而选择颜色。

添加以下XML至你的布局中:

?


1

2

3

4

<com.larswerkman.holocolorpicker.ColorPicker

    android:id="@+id/picker"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

To add a Saturation/Value bar to your layout add this to your xml

?


1

2

3

4

<com.larswerkman.holocolorpicker.SVBar

    android:id="@+id/svbar"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

The same goes for the Opacity bar

?


1

2

3

4

<com.larswerkman.holocolorpicker.OpacityBar

    android:id="@+id/opacitybar"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

Saturation bar

?


1

2

3

4

<com.larswerkman.holocolorpicker.SaturationBar

    android:id="@+id/saturationbar"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

and a Value bar

?


1

2

3

4

<com.larswerkman.holocolorpicker.ValueBar

    android:id="@+id/valuebar"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

To connect the bars with the colorpicker and to get the selected color.

?


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

ColorPicker picker = (ColorPicker) findViewById(R.id.picker);

SVBar svBar = (SVBar) findViewById(R.id.svbar);

OpacityBar opacityBar = (OpacityBar) findViewById(R.id.opacitybar);

SaturationBar saturationBar = (SaturationBar) findViewById(R.id.saturationbar);

ValueBar valueBar = (ValueBar) findViewById(R.id.valuebar);

picker.addSVBar(svBar);

picker.addOpacityBar(opacityBar);

picker.addSaturationBar(saturationBar);

picker.addValueBar(valueBar);

//To get the color

picker.getColor();

//To set the old selected color u can do it like this

picker.setOldCenterColor(picker.getColor());

// adds listener to the colorpicker which is implemented

//in the activity

picker.setOnColorChangedListener(this);

项目主页:http://www.open-open.com/lib/view/home/1389353422164

时间: 2024-08-11 07:43:06

Android圆环形颜色选择器:HoloColorPicker的相关文章

Android 颜色渲染(一) 颜色选择器 ColorPickerDialog剖析

版权声明:本文为博主原创文章,未经博主允许不得转载. Android 颜色选择器之ColorPickerDialog剖析 有这样一个需求,可以让用户自定义背景颜色,这就需要提供一个颜色选择器给用户. 在Android 中,如何实现这样的功能呢,遇到这种需求是,先查看一下ApiDemos,是否已经有相关的实例,果然,找到了一个可以参考的demo:ColorPickerDialog 我已经把apidemos导入到eclipse中,请看截图: 我们要找的就是这个ColorPickerDialog,在c

自定义实现简单的Android颜色选择器(附带源码)

在写Android App过程中需要一个简单的颜色选择器,Android自带的ColorPicker和网上的一些ColorPicker都太高端了,都实现了颜色渐变功能,我要的不需要那么复杂,只想提供几种颜色供User去选择.于是就自己自定义实现一个Simple ColorSelector,效果图如下 如何去使用这个ColorSelector呢,见下面代码: final ColorSelectorDialog colorDialog = new ColorSelectorDialog( mCont

颜色选择器学习

说是颜色选择器,其实我本来不是用弄这个,只是想搞搞渐变的,但是在网上收集资料的时候感觉好像是一起的所以我就说都一起看看吧 其实说到颜色选择器网上的资料一大把,基本上都是基于android apiDemo做的研究,我也不例外: 代码网上很多我就直接贴了:都有注释: 主要介绍下这个: SweepGradient 颜色渐变方向非环形,而是以某点为圆心呈扇形扫过. SweepGradient的构造函数: public SweepGradient(float cx, float cy, int[] col

用HTML5canvas绘制一个圆环形的进度表示

先看一下画出来的效果,如下图,这样一个圆环形的进度.  我这里使用HTML5的Canvas来要制作这样一个圆环形的进度, 首先是HTML页面,HTML5的文档标识是: <!DOCTYPE html> 这个文档标识要比HTML4的简单多了. 第二步,在页面上创建一个Canvas画布元素: <canvas class="process" width="48px" height="48px">61%</canvas>

每日总结 - android设置背景颜色报错

每天坚持总结,总会发生质变! 今天给radiobutton设置背景颜色报错,信息如下: item> tag requires a 'drawable' attribute or child tag defining a drawable 解决方法: 你不能将颜色选择器用在background上,应该使用drawable selector. 1 <selector xmlns:android="http://schemas.android.com/apk/res/android&quo

android 设置字体颜色、EditText自动输入转换成大写字母的多种方式

在TextView上面设置某一个字的字体颜色为指定颜色时,可以通过java类SpannableString类和Html语言来实现. (一)SpannableString类方式 private void setText(TextView t){ String text = t.getText().toString().trim(); SpannableString span = new SpannableString(text); span.setSpan(new ForegroundColorS

android中的颜色设置

1.在android中经常看到设置的颜色为八位的十六进制的颜色值,例如: 1 2 3 public static final class color {     public static final int lightblue=0x7f040000; } 或者在Java中tx.setTextColor(0xffff00f); 说明: 0xffff00ff是int类型的数据,分组一下0x|ff|ff00ff,0x表示颜色整数的标记,ff表示透明度,f00f表示色值,注意:0x后面ffff00ff

jquery颜色选择器

本站下载 第二种:纯JAVASCRIPT: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2311"> <title>DW调色板</title> <script> var ColorHex=new Array('00','33','66','99','CC','FF') var SpColo

Android笔记之日期选择器

1.主代码 /** * 日期选择器 */ private DatePickerDialog datePickerDialog; /** * 年 */ private int mYear=1993; /** * 月 */ private int mMonth=12-1; /** * 日 */ private int mDay=16; ......................... //构造函数包括mYear, mMonth, mDay用来显示初始日期,同时设置监听 datePickerDial