Skip to content

Commit

Permalink
Update library usage
Browse files Browse the repository at this point in the history
  • Loading branch information
naz013 authored Jun 11, 2017
1 parent 205179c commit 0763154
Showing 1 changed file with 78 additions and 4 deletions.
82 changes: 78 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,84 @@ Simple color picker library for Android

<img src="https://github.com/naz013/ColorSlider/raw/master/res/screenshow.png" width="400" alt="Screenshot">

## Installation
TODO: Describe the installation process
## Usage
TODO: Write usage instructions
Download
--------
Download latest version with Gradle:
```groovy
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.naz013:ColorSlider:1.0.1'
}
```

Usage
-----
Default (Material colors picker):
```xml
<com.github.naz013.colorslider.ColorSlider
android:id="@+id/color_slider"
android:layout_width="match_parent"
android:layout_height="36dp" />
```
Gradient (Params: cs_from_color, cs_to_color, cs_steps):
via XML:
```xml
<com.github.naz013.colorslider.ColorSlider
android:id="@+id/color_slider"
android:layout_width="match_parent"
app:cs_from_color="#F44336"
app:cs_steps="500"
app:cs_to_color="#40F44336"
android:layout_height="36dp" />
```
in code:
```java
colorSlider.setGradient(@ColorInt int fromColor, @ColorInt int toColor, int steps)
```


Array of color resources (Params: cs_colors):
via XML:
```xml
<com.github.naz013.colorslider.ColorSlider
android:id="@+id/color_slider"
android:layout_width="match_parent"
app:cs_colors="@array/colors"
android:layout_height="36dp" />
```
in code:
```java
colorSlider.setColors(@ColorInt int[] colors)
```


String array of hex colors (Params: cs_hex_colors):
via XML:
```xml
<com.github.naz013.colorslider.ColorSlider
android:id="@+id/color_slider"
android:layout_width="match_parent"
app:cs_hex_colors="@array/hex_colors"
android:layout_height="36dp" />
```
in code:
```java
colorSlider.setHexColors(String[] hexColors)
```

Also you can set listener for color picker:
```java
colorSlider.setListener(new ColorSlider.OnColorSelectedListener() {
@Override
public void onColorChanged(int position, int color) {
updateView(color);
}
})
```


License
-------
Expand Down

0 comments on commit 0763154

Please sign in to comment.