QuadFlask / colorpicker

🍭color picker for android
1.22k stars 219 forks source link

How to change the background color of dialog same as your #99

Open Kevin-Luong opened 6 years ago

Kevin-Luong commented 6 years ago

Hi QuadFlask

Your library is great! I'm using it for studying. I have a question that how to change the background color of the color picker dialog from white (mine) to dark (yours) like pictures below. As I add this library and execute it, it is a just white color for the dialog. I tried to find out how to change, however, I'm still have not found the solution yet. I think the dark color is more beautiful than white.

I hope that you may give me the solution for it. Thank you, Kevin.

(Mine) screenshot_20180515-164510 1

(Your) screenshot_20180515-164458 1

mousexaker commented 6 years ago

You can use custom theme for dialog like this

<style name="ColorPickerDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="android:background">@color/colorPrimaryDark</item>
</style>
ColorPickerDialogBuilder
    .with(context, R.style.ColorPickerDialogTheme)
    .setTitle("Choose color")
    .initialColor(currentBackgroundColor)
    .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER)
    .density(12)
    .setOnColorSelectedListener(new OnColorSelectedListener() {
        @Override
        public void onColorSelected(int selectedColor) {
            toast("onColorSelected: 0x" + Integer.toHexString(selectedColor));
        }
    })
    .setPositiveButton("ok", new ColorPickerClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) {
            changeBackgroundColor(selectedColor);
        }
    })
    .setNegativeButton("cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    })
    .build()
    .show();