项目作者: naz013

项目描述 :
Simple color picker library for Android
高级语言: Java
项目地址: git://github.com/naz013/ColorSlider.git
创建时间: 2017-06-11T16:40:44Z
项目社区:https://github.com/naz013/ColorSlider

开源协议:Apache License 2.0

下载


ColorSlider

Simple color picker library for Android

Screenshot

Screenshot

Sample APP

Download

Google Play

Download

Download latest version with Gradle:

  1. repositories {
  2. maven { url 'https://jitpack.io' }
  3. }
  4. dependencies {
  5. implementation 'com.github.naz013:ColorSlider:1.0.6'
  6. }

AndroidX version:

  1. dependencies {
  2. implementation 'com.github.naz013:ColorSlider:2.0.6'
  3. }

Usage

Default (Material colors picker):

  1. <com.github.naz013.colorslider.ColorSlider
  2. android:id="@+id/color_slider"
  3. android:layout_width="match_parent"
  4. android:layout_height="36dp" ></com.github.naz013.colorslider.ColorSlider>

Gradient (Params: cs_from_color, cs_to_color, cs_steps):
via XML:

  1. <com.github.naz013.colorslider.ColorSlider
  2. android:id="@+id/color_slider"
  3. android:layout_width="match_parent"
  4. app:cs_from_color="#F44336"
  5. app:cs_steps="500"
  6. app:cs_to_color="#40F44336"
  7. android:layout_height="36dp" ></com.github.naz013.colorslider.ColorSlider>

in code:

  1. colorSlider.setGradient(@ColorInt int fromColor, @ColorInt int toColor, int steps)

Gradient from array of colors:
in code:

  1. colorSlider.setGradient(@ColorInt int[] colors, int steps)

Array of color resources (Params: cs_colors):
via XML:

  1. <com.github.naz013.colorslider.ColorSlider
  2. android:id="@+id/color_slider"
  3. android:layout_width="match_parent"
  4. app:cs_colors="@array/colors"
  5. android:layout_height="36dp" ></com.github.naz013.colorslider.ColorSlider>

in code:

  1. colorSlider.setColors(@ColorInt int[] colors)

String array of hex colors (Params: cs_hex_colors):
via XML:

  1. <com.github.naz013.colorslider.ColorSlider
  2. android:id="@+id/color_slider"
  3. android:layout_width="match_parent"
  4. app:cs_hex_colors="@array/hex_colors"
  5. android:layout_height="36dp" ></com.github.naz013.colorslider.ColorSlider>

in code:

  1. colorSlider.setHexColors(String[] hexColors)

Also you can set listener for color picker:

  1. colorSlider.setListener(new ColorSlider.OnColorSelectedListener() {
  2. @Override
  3. public void onColorChanged(int position, int color) {
  4. updateView(color);
  5. }
  6. })

License

  1. Copyright 2019 Nazar Suhovich
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.