🎨 A color picker for Android. Pick a color using color wheel and slider (HSV & alpha).

Overview

ColorPicker gitHub release platform Android Arsenal license

English | 中文

A ColorPicker for Android. Pick a color using color wheel and slider (HSV & alpha).

Gradle

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

Replace ${latestVersion} with the latest version code. See releases.

Usage

Using ColorPickerPopup

new ColorPickerPopup.Builder(this)
        .initialColor(Color.RED) // Set initial color
        .enableBrightness(true) // Enable brightness slider or not
        .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) {

            }
        });

Using ColorPickerView

  • Add ColorPickerView into your layout xml:
<top.defaults.colorpicker.ColorPickerView
    android:id="@+id/colorPicker"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:enableBrightness="true"
    app:enableAlpha="true"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

See top_defaults_view_color_picker_attrs.xml for all supported attributes.

  • Implement ColorObserver and subscribe to ColorPickerView to receive color updates from the ColorPickerView:
colorPickerView.subscribe((color, fromUser) -> {
    // use the color
});
  • Set initial color:
colorPickerView.setInitialColor(0x7F313C93);
  • Reset to initial color:
colorPickerView.reset();

See a complete usage in the app sample code.

License

Copyright 2018 Hong Duan

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • ColorPickerView onMeasure does not account for constrained by height

    ColorPickerView onMeasure does not account for constrained by height

    If I try to constrain the color picker view with height instead of width, it does not show up on the screen at all.

    ` android:layout_width="wrap_content" android:layout_height="0dp"

    `

    device-2018-09-06-162331 device-2018-09-06-162404

    opened by faridzidan 6
  • ClassDefException

    ClassDefException

    I tried using the latest version 1.1.5 in my project and when i click on a button to open the color picker it crashes and displays the following exception: java.lang.NoClassDefFoundError: Failed resolution of: Ltop/defaults/checkerboarddrawable/CheckerboardDrawable; at top.defaults.colorpicker.AlphaSliderView.onDraw(AlphaSliderView.java:43) at android.view.View.draw(View.java:18398) at android.view.View.updateDisplayListIfDirty(View.java:17376) at android.view.View.draw(View.java:18160) at android.view.ViewGroup.drawChild(ViewGroup.java:3968) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3754) at android.view.View.updateDisplayListIfDirty(View.java:17371) at android.view.View.draw(View.java:18160) at android.view.ViewGroup.drawChild(ViewGroup.java:3968) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3754) at android.support.constraint.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1964) at android.view.View.updateDisplayListIfDirty(View.java:17371) at android.view.View.draw(View.java:18160) at android.view.ViewGroup.drawChild(ViewGroup.java:3968) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3754) at android.view.View.draw(View.java:18401) at android.view.View.updateDisplayListIfDirty(View.java:17376) at android.view.View.draw(View.java:18160) at android.view.ViewGroup.drawChild(ViewGroup.java:3968) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3754) at android.view.View.updateDisplayListIfDirty(View.java:17371) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:722) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:728) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:836) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3168) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2964) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2552) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1537) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:959) at android.view.Choreographer.doCallbacks(Choreographer.java:734) at android.view.Choreographer.doFrame(Choreographer.java:670) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:945) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) 10-10 18:57:21.573 23645-23645/com.monstarlab.instantmac E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "top.defaults.checkerboarddrawable.CheckerboardDrawable" on path: DexPathList[[zip file "/data/app/com.monstarlab.instantmac-1/base.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.monstarlab.instantmac-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.monstarlab.instantmac-1/lib/arm, /data/app/com.monstarlab.instantmac-1/base.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_dependencies_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_1_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_2_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_3_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_4_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_5_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_6_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_7_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_8_apk.apk!/lib/armeabi-v7a, /data/app/com.monstarlab.instantmac-1/split_lib_slice_9_apk.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]

    opened by maximus9600 5
  • Popup Buttons

    Popup Buttons

    Hey, great library! It would be nice however if the Cancel and Choose buttons in the ColorPickerPopup were actual buttons (consistent look and feel with the rest of the app) instead of TextViews, and were on the bottom of the dialog like a standard Android popup dialog.

    opened by tgvoskuilen 3
  • Observer callback and initial color value of xFF000000

    Observer callback and initial color value of xFF000000

    Using ColorPickerView in a xml layout with enableAlpha="false" and initializing view by calling setInitialColor() with opaque Black color #FF000000

    After that, observer always invokes callback with color #FF000000 no matter where user taps on the color wheel to pick colors.

    User has to tap on the seek bar for the observer callback to actually change the color from black.

    opened by faridzidan 2
  • Cannot resolve symbol

    Cannot resolve symbol

    I'm a total beginner in AS. I'm trying to use your library for my app and can't get it working.

    colorPickerView.subscribe((color, fromUser) -> { // use the color }); colorPickerView is colored red (cannot resolve symbol) what did I forgot?

    Thank you!

    opened by TadyTheFish 2
  • Bad documentation

    Bad documentation

    Your readme.md shows the package name for a layou as: <top.defaults.view.ColorPickerView />

    It really is: <top.defaults.colorpicker.ColorPickerView />

    You should fix that.

    opened by JeffAtPropeller 1
  • [Request] add option to show/hide brightnessSliderView from ColorPicker

    [Request] add option to show/hide brightnessSliderView from ColorPicker

    Hello,

    I'm currently using this color picker as it works with API 28, I like it so far!

    However, in my situation, I'm color picker view to to get rgb colors only for communication. The brightness slider currently a waste of space for my current project.

    Example I would like to see within layout: app:enableBrightness="Boolean" or programmatically: .enableBrightness(Boolean)

    Thanks!

    opened by LossyDragon 1
  • .show() method should be callable without viewparent

    .show() method should be callable without viewparent

    I tried this color picker with i a project and came along an issue, regarding the show method. So the goal is just to pick a color and store it in an variable, but to do this a view is mandatory, what in this case is not needed.

    So could you maybe add the possibility to set the view null, so that no parent is needed ?

    opened by D4rkness 1
  • 我导入了依赖但是不能用

    我导入了依赖但是不能用

    这是我的build.gradle文件

    plugins {
        id 'com.android.application'
    }
    android {
        compileSdk 32
    
        defaultConfig {
            applicationId "com.light.ss"
            minSdk 24
            targetSdk 32
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    dependencies {
        implementation 'androidx.appcompat:appcompat:1.3.0'
        implementation 'com.google.android.material:material:1.4.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'androidx.test.ext:junit:1.1.3'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
        implementation 'com.github.danielnilsson9.colorpickerview:library:1.0.1'
    }
    
    opened by NetWangPu 0
  • method does not override or implement a method from a supertype

    method does not override or implement a method from a supertype

    on version 1.1.6 when using your example code

    `new ColorPickerPopup.Builder(this) .initialColor(Color.RED) // Set initial color .enableBrightness(true) // Enable brightness slider or not .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) {
    
            }
        });
    

    `

    on this line

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

            }`
    

    this error comes "method does not override or implement a method from a supertype"

    it is fine on version 1.1.5

    opened by amin1985 1
  • Add ability to change color of black arrow on color slider view

    Add ability to change color of black arrow on color slider view

    With dark backgrounds, the arrow (black) on the color slider view is difficult to see (impossible to see if the background is pure black). It would be nice to be able to change the color of this arrow to something visible.

    opened by ardnew 4
  • May I know what is the idea behind ThrottledTouchEventHandler?

    May I know what is the idea behind ThrottledTouchEventHandler?

    Thank you for producing such wonderful library.

    When I look at ThrottledTouchEventHandler, I understand its purpose is to avoid from handling too frequent (Anything not more than 16ms is considered too frequent) ACTION_DOWN and ACTION_MOVE.

    But, may I know why do we need to perform such filtering. My initial thought is, perhaps the initial idea is avoiding too frequent call to update(MotionEvent event), which may cause the entire app not responsive.

    But, even if I avoid the filtering, I notice the app still as smooth as butter.

    Am I missing out something?

    Thank you

    opened by yccheok 0
Releases(1.1.6)
Owner
Hong Duan
To be a better man. Focus on Android development.
Hong Duan
For color lovers! A simple but powerful Android color picker

#DEPRECATED Credits for the logo goes to Hafiz Ahmmed (https://github.com/hafizahmmed) ColorBox library Features Dynamic color preview; Change the col

Enrico D'Ortenzio 53 Apr 8, 2021
Color picker library for Android

andColorPicker — Color Picker library for Android ?? Handy, ?? flexible, and ⚡ lightning-fast Android color picker views and utilities. ?? Features Cl

side.codes 216 Jan 7, 2023
Beautiful color picker dialog for Android 9+

Color-O-Matic Beautiful Color Picker dialog for Android 9+ based on VintageChroma by Pavel Sikun. Screenshots at the end of the file. Repository Add t

null 43 Jun 5, 2022
Color Picker — beautiful library for Android

Color Picker — beautiful library for Android Features Simple dialog builder ARGB, RGB & HSV color models Dark theme support Sliders with gradient back

Dmitriy 35 Dec 20, 2022
Jetpack Compose Color Picker

Bundle of Stylish customizable Color pickers, selectors, colorful sliders written with Jetpack Compose enables users to choose from HSL, HSV or RGB color modes to pick Solid colors or gradients.

Smart Tool Factory 34 Nov 29, 2022
Color.kt is a modern color science library for Kotlin Multiplatform and Java.

Color.kt is a modern color science library for Kotlin Multiplatform and Java. It includes modern perceptually-uniform color spaces and color appearance models, such as Oklab and ZCAM.

Danny Lin 45 Oct 11, 2022
Color.kt is a modern color science library for Kotlin Multiplatform and Java.

Color.kt is a modern color science library for Kotlin Multiplatform and Java. It includes modern perceptually-uniform color spaces and color

SOSP-OS 0 Jan 21, 2022
A modern color science library for Kotlin Multiplatform and Java

Color.kt Color.kt is a modern color science library for Kotlin Multiplatform and Java. It includes modern perceptually-uniform color spaces and color

Weeb Project (WIP) 0 Oct 21, 2021
App-level wallpaper color palette generation for Android 5.0+

MonetCompat is an app-level implementation of kdrag0n's custom Monet implementation, based on his android12-extensions module. With MonetCompat you can generate color palettes from a user's wallpaper and use them anywhere in your app. It supports Android 5.0 and above (in Palette compatibility mode) and Android 8.1 and above in normal mode.

Kieron Quinn 145 Dec 18, 2022
Match a wallpaper to your color scheme

ImageTheming Change the color palette of an image to match your theme. Getting Started Use java -jar path/to/ImageTheming.jar -h to get all available

null 230 Dec 25, 2022
Utility library that extends Jetpack Compose Colors with Material Design2 colors, Color swatches like in Flutter

????♾ Utility library that expands Compose Colors with Material Design2 colors, color swatches, Material Design 3 Tonal Palettes, color names, and utility functions to convert between HSL, HSV, RGB, HCT models and to HEX or from HEX

Smart Tool Factory 18 Dec 13, 2022
A list of most useful resources for designing android apps such as all material colors and dimens, 180 Gradient background + html, social, flat, fluent, metro colors.

Timer UI Login UI Fitness UI Material-Resources-Library A list of most useful resources for designing android apps such as all material colors and dim

Next 37 Jul 24, 2022
Android Material Design Colors

Android-Material-Design-Colors Android-Material-Design-Colors provides color definitions of the Material Design. Demo Usage R.color.md_color_value or

wada811 197 Jan 2, 2023
A component that provides an HSV color picker, written in Jetpack compose🎨

A component that provides an HSV color picker, written in Jetpack compose??

GoDaddy 270 Dec 30, 2022
Slider-Gallery-Zoom: image slider for android supporting indicator and auto scroll with clicking on image

image slider supporting indicator and auto scroll with clicking on image to open full screen image slider swipe and pinch zoom gestures like gallery,just pass your images and the position of the current image.

Mahmoud Elian 3 May 28, 2022
A View on which you can freely draw, customizing paint width, alpha and color, and take a screenshot of the content. Useful for note apps, signatures or free hand writing.

FreeDrawView A View that let you draw freely on it. You can customize paint width, alpha and color. Can be useful for notes app, signatures or hands-f

Riccardo Moro 643 Nov 28, 2022
Simple View to change Brush Size, Alpha and Color

BrushView Simple View to change Brush Size, Alpha and Color Screenshots How to install In your build.gradle project allprojects { repositories {

Andres Ruiz 16 Jun 28, 2018
Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image selection.

Awesome Image Picker Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image sel

Prabhakar Thota 162 Sep 13, 2022
Market Watch is Android app using Alpha Vantage API. Live stock and market data.

Donate If you like this app please donate Bitcoin: bc1qwqqpuy54qfja7h5dzpd9swgrnkql02t8cacn62 About this app Market Watch allows to watch and track s

Krzysztof Kobiałka 1 May 22, 2022
Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.

ChiliPhotoPicker Made with ❤️ by Chili Labs. Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it w

Chili Labs 394 Jan 2, 2023