duanhong169 / colorpicker Goto Github PK
View Code? Open in Web Editor NEW🎨 A color picker for Android. Pick a color using color wheel and slider (HSV & alpha).
License: Apache License 2.0
🎨 A color picker for Android. Pick a color using color wheel and slider (HSV & alpha).
License: Apache License 2.0
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
Is there a way to change the selector shape?
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.
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 ?
When using AppCompat DayNight theme, and it is switched to night mode, the OK/Cancel text becomes white by default. As the background of the ColorPickerPopup is also forced white, they become invisible.
Worked around it by now with some reflection, but it'd be nice to have a proper fix.
Suggestions are to:
(a) force the text dark as you force the background white, or
(b) apply dark background in night mode
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.
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
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!
my current implementation is
class EditSubPanelDrawView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) {
@IntRange(from = 0x0, to = 0xFF)
private var alphaValue : Int = 0
@ColorInt
private var colorValue : Int = getRandomRainbowColor(context)
private val mComponentLayoutParams = LinearLayout.LayoutParams(dpToPx(200f).toInt(), dpToPx(30f).toInt()).apply{
weight = 1f
gravity = Gravity.CENTER
}
private val mColorPickerView : ColorPickerView by lazy {
ColorPickerView(context).apply {
layoutParams = mComponentLayoutParams
setEnabledAlpha(true)
setEnabledBrightness(true)
setInitialColor(colorValue)
subscribe { color, fromUser, shouldPropagate ->
Timber.d("ColorPickerView newColor: $color")
colorValue = color
}
}
}
private val mAlphaSeekBar : SeekBar by lazy {
SeekBar(context).apply {
// min = 0
max = 0xFF
layoutParams = mComponentLayoutParams
setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
alphaValue = progress
Timber.d("mAlphaSeekBar progress: $progress, alphaValue:$alphaValue")
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
}
})
}
}
init {
orientation = LinearLayout.VERTICAL
gravity = Gravity.CENTER
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply {
val xPadding = dpToPx(30f).toInt()
val yPadding = dpToPx(40f).toInt()
setPadding(xPadding, yPadding, xPadding, yPadding)
}
addView(mAlphaSeekBar)
// 16776943 x 63??
addView(mColorPickerView)
}
}
crash log
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1051)
at android.graphics.Bitmap.createBitmap(Bitmap.java:999)
at android.graphics.Bitmap.createBitmap(Bitmap.java:949)
at android.graphics.Bitmap.createBitmap(Bitmap.java:910)
at top.defaults.colorpicker.AlphaSliderView.onSizeChanged(AlphaSliderView.java:36)
at android.view.View.sizeChange(View.java:20974)
at android.view.View.setFrame(View.java:20916)
at android.view.View.layout(View.java:20819)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1193)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:880)
at com.google.android.material.bottomsheet.BottomSheetBehavior.onLayoutChild(BottomSheetBehavior.java:265)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:898)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:944)
at android.view.View.layout(View.java:20822)
at android.view.ViewGroup.layout(ViewGroup.java:6401)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2948)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2635)
2019-02-04 12:31:39.892 7780-7780/com.deltapath.imagician.debug E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1779)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7810)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
这是我的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'
}
It would be nice to have feature to customize the views
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.
Hi, we'd like to use this library but can only rely on libraries that use Android X, do you have any plans on migrating soon? Would be great, thanks!
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]]
Is there a way to forcefully dismiss the color picker.
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.
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!
I'mg trying to use your library but it's showing this error when Syncing.
Failed to resolve: com.github.duanhong169:colorpicker:1.1.6
How to fix this error?
i want to use onColor (realtime) method but it is final
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.