项目作者: emkayDauda

项目描述 :
Lightweight color-picker library for android
高级语言: Kotlin
项目地址: git://github.com/emkayDauda/ColorSlider.git
创建时间: 2020-01-04T08:57:35Z
项目社区:https://github.com/emkayDauda/ColorSlider

开源协议:Apache License 2.0

下载


ColorSlider Library

Lightweight color-picker library for Android.

Screenshots

Slider in action

Getting started

Adding library

1) Using JitPack

Add maven url to root level build.gradle file.

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }
  7. }

2) Import module to your project level build.gradle file

  1. dependencies {
  2. ...
  3. implementation 'com.github.emkayDauda:ColorSlider:$current_version'
  4. }

Using library

1) Create String Array of colors in strings.xml file

  1. <resources>
  2. //other strings
  3. ...
  4. <string-array name="slider_colors">
  5. <item>#E57373</item>
  6. <item>#BA68C8</item>
  7. <item>#64B5F6</item>
  8. <item>#81C784</item>
  9. <item>#FFF176</item>
  10. <item>#FFB74D</item>
  11. <item>#90A4AE</item>
  12. <item>#454849</item>
  13. </string-array>
  14. </resources>

2) Add ColorSlider to layout

  1. <com.emkaydauda.colorslider.ColorSlider
  2. android:id="@+id/colorSelector"
  3. android:layout_width="0dp"
  4. android:layout_height="wrap_content"
  5. app:layout_constraintEnd_toEndOf="parent"
  6. android:layout_marginEnd="20dp"
  7. android:layout_marginStart="20dp"
  8. app:colors="@array/slider_colors"
  9. app:layout_constraintStart_toStartOf="parent"
  10. app:layout_constraintTop_toBottomOf="@id/colorSelectorLabel"></com.emkaydauda.colorslider.ColorSlider>

3) Finally, listen for color changes in activity

  1. colorSelector.addListener { color ->
  2. someView.setBackgroundColor(color)
  3. }

Examples

Complete code for the app featured in screenshots is available in the app folder