zoukankan      html  css  js  c++  java
  • 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);

    framed_colorpicker.png

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

  • 相关阅读:
    排序三 直接插入排序
    编写你的第一个django应用程序2
    编写你的第一个web应用程序1
    你被体制化了吗
    服务器安装tensorflow导入模块报错Illegal instruction (core dumped)
    查看数据库里有没有数据
    python实现贪吃蛇
    在pycharm中执行脚本没有报错但输出显示Redirection is not supported.
    linux安装redis
    pycharm快捷键
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/4581581.html
Copyright © 2011-2022 走看看