Android 颜色选择器 ColorPicker

码农软件 · 软件分类 · 选择器(Picker) · 2019-06-06 07:29:15

软件介绍

ColorPicker

一款标准的Android颜色选择器,使用HSV和透明度选择颜色。

Gradle

dependencies {
    implementation 'com.github.duanhong169:colorpicker:${latestVersion}'
    ...
}

${latestVersion}请替换为当前最新版本号,见 releases.

Usage

使用 ColorPickerPopup

new ColorPickerPopup.Builder(this)
        .initialColor(Color.RED) // Set initial color
        .enableAlpha(true) // Enable alpha slider or not
        .okTitle("Choose")
        .cancelTitle("Cancel")
        .showIndicator(true)
        .showValue(true)
        .build()
        .show(v, new ColorPickerPopup.ColorPickerObserver() {
            @Override
            public void onColorPicked(int color) {
                v.setBackgroundColor(color);
            }

            @Override
            public void onColor(int color, boolean fromUser) {

            }
        });

使用 ColorPickerView

  • 将 ColorPickerView 添加到 layout xml :

<top.defaults.view.ColorPickerView
    android:id="@+id/colorPicker"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:enableAlpha="true"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

查阅 top_defaults_view_color_picker_attrs.xml 了解所有支持的属性。

  • 执行 ColorObserver 并订阅 ColorPickerView 以从 ColorPickerView 接收颜色更新:

colorPickerView.subscribe((color, fromUser) -> {
    // use the color
});

  • 设置初始颜色:

colorPickerView.setInitialColor(0x7F313C93);

  • 重置初始颜色:

colorPickerView.reset();

更详细的使用方法请参见示例。

本文地址:https://codercto.com/soft/d/7354.html

白话大数据与机器学习

白话大数据与机器学习

高扬、卫峥、尹会生 / 机械工业出版社 / 2016-6 / 69

本书通俗易懂,有高中数学基础即可看懂,同时结合大量案例与漫画,将高度抽象的数学、算法与应用,与现实生活中的案例和事件一一做了关联,将源自生活的抽象还原出来,帮助读者理解后,又带领大家将这些抽象的规律与算法应用于实践,贴合读者需求。同时,本书不是割裂讲解大数据与机器学习的算法和应用,还讲解了其生态环境与关联内容,让读者更全面地知晓渊源与未来,是系统学习大数据与机器学习的不二之选: ·大数据产业......一起来看看 《白话大数据与机器学习》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具