Skip to content

HexagonalColorPicker for android to create color picker view or preferences

License

Notifications You must be signed in to change notification settings

rhidasi/hexagonalcolorpicker

Repository files navigation

HexagonalColorPicker for Android

Simple color picker for Android with a hexagonal design.

The number of color swatches can be configured (parameter "paletteRadius").

Can be used as custom:

  • View
  • AlertDialog (androidx.appcompat.app.AlertDialog)
  • Preference (androidx.preference.Preference).

HexagonalColorPicker animation

Setup

Inside the app/build.gradle file add the following dependencies:

dependencies {
    implementation 'sk.hidasi:hexagonal-color-picker:1.2.2'
}

The library is hosted on JCenter:

repositories {
    jcenter()
}

View

Color Picker can be put in XML layout just like any other android view.

You can optionally define color change listener (see HexagonalColorPicker#setListener).

Example:

    <sk.hidasi.hexagonalcolorpicker.HexagonalColorPicker
        android:id="@+id/hexagonalColorPicker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        app:paletteRadius="3" />

Screenshots:

Screenshot 1

Screenshot 1 dark

AlertDialog

The usage of AlertDialog class is really straightforward.

Example:

    HexagonalColorPickerDialog dialog = new HexagonalColorPickerDialog(getContext(), R.string.color_picker_default_title, paletteRadius, initialColor, listener);
    dialog.show();

Screenshots:

Screenshot 2

Screenshot 2 dark

Preference

Color Picker can be used also on Preference Screen. Usage is the same as for any other preferences. You can provide default, initial color value by setting android:defaultValue attribute. Value selected in the dialog will be stored under the key provided with android:key attribute.

Example:

    <sk.hidasi.hexagonalcolorpicker.HexagonalColorPickerPreference
        android:key="key_color"
        android:title="@string/color"
        android:summary="@string/tap_to_change_color"
        android:defaultValue="@color/red"
        app:paletteRadius="3" />

Screenshots:

Screenshot 3

Screenshot 4

Screenshot 3 dark

Screenshot 4 dark

HexagonalColorPickerExample

Provided example application demonstrates the usage of HexagonalColorPicker.

You can install the application from Google Play for easy access:

Get it on Google Play

License

Code is licensed under the Apache License, Version 2.0.

About

HexagonalColorPicker for android to create color picker view or preferences

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages