A simple color picker widget for Android
Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
build.gradle
kscolorpicker-release.aar
kscolorpicker.iml
proguard-rules.pro

README.md

A very simple color picker widget.

Installation:

  • Get the .aar file from here.
  • Right click on the Android Studio project and click "Open Module Settings".
  • Click the plus button over the module list.
  • Select "import .jar or .aar file" from the list. Select the .aar file you have downloaded before.
  • On "Dependencies" tab, add the imported module to the list.

That should be all.

If gradle build returns with an error, check what the error message suggests you to do, or try adding this line under your manifest's application tag:

tools:replace="android:icon"

Usage:

activity_main.xml

  <com.karacasoft.colorpicker.ColorPickerView
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/color_picker_view"
  android:layout_below="@+id/textView"
  android:padding="20dp"
  android:layout_alignParentLeft="true"
  android:layout_alignParentStart="true" />

MainActivity.java

  ...
  
  ColorPickerView colorPicker;
  TextView tv;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      colorPicker = (ColorPickerView) findViewById(R.id.color_picker_view);
      tv = (TextView) findViewById(R.id.textView);
      colorPicker.setOnColorPickListener(new ColorPickerView.OnColorPickListener() {
          @Override
          public void onColorPick(int color) {

          }
      });

      colorPicker.setOnPinMoveListener(new ColorPickerView.OnPinMoveListener() {
          @Override
          public void onPinMove(int color, float x, float y) {
              tv.setText("R:" + Color.red(color) + " G:" + Color.green(color) + " B:" + Color.blue(color));
          }
      });

  }
  ...