Skip to content

rtugeek/ColorSeekBar

Repository files navigation

ColorSeekbar

ScreenShot:

ColorSeekbar Attrs

<declare-styleable name="ColorSeekBar">
    <attr name="colorSeekBarColorSeeds" format="reference" />
    <attr name="colorSeekBarBarHeight" format="dimension" />
    <attr name="colorSeekBarProgress" format="integer" />
    <attr name="colorSeekBarRadius" format="dimension" />
    <attr name="colorSeekBarMaxProgress" format="integer" />
    <attr name="colorSeekBarVertical" format="boolean" />
    <attr name="colorSeekBarShowThumb" format="boolean" />
    <attr name="colorSeekBarBorderColor" format="color" />
    <attr name="colorSeekBarBorderSize" format="dimension" />
</declare-styleable>

AlphaSeekbar Attrs

<declare-styleable name="AlphaSeekBar">
    <attr name="alphaSeekBarHeight" format="dimension" />
    <attr name="alphaSeekBarRadius" format="dimension" />
    <attr name="alphaSeekBarShowGrid" format="boolean" />
    <attr name="alphaSeekBarShowThumb" format="boolean" />
    <attr name="alphaSeekBarSizeGrid" format="dimension" />
    <attr name="alphaSeekBarProgress" format="integer" />
    <attr name="alphaSeekBarVertical" format="boolean" />
    <attr name="alphaSeekBarMaxProgress" format="integer" />
    <attr name="alphaSeekBarBorderColor" format="color" />
    <attr name="alphaSeekBarBorderSize" format="dimension" />
    <attr name="alphaSeekBarDirection" format="enum">
        <enum name="LEFT_TO_RIGHT" value="0"/>
        <enum name="RIGHT_TO_LEFT" value="1"/>
        <enum name="TOP_TO_BOTTOM" value="2"/>
        <enum name="BOTTOM_TO_TOP" value="3"/>
    </attr>
</declare-styleable>

Gradle:

Release API Android Arsenal

Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

implementation 'com.github.rtugeek:colorseekbar:2.0.3'

Usage

XML

<com.rtugeek.android.colorseekbar.ColorSeekBar 
    android:id="@+id/colorSeekBar"
    android:layout_width="match_parent"
    app:colorSeeds="@array/material_colors"
    android:layout_height="wrap_content" />

<com.rtugeek.android.colorseekbar.AlphaSeekBar 
    android:id="@+id/alphaSeekBar"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" />

Kotlin

colorSeekBar.maxProgress = 1000
colorSeekBar.progress = 50
colorSeekBar.borderColor = Color.BLACK
colorSeekBar.borderRadius = 10
colorSeekBar.borderSize = 10
colorSeekBar.thumbDrawer = DefaultThumbDrawer(30,Color.WHITE,Color.BLUE)
colorSeekBar.isVertical = false
colorSeekBar.barHeight = 10
colorSeekBar.color = Color.BLACK // or colorSeekBar.progress = 100
//lock thumb
colorSeekBar.isEnabled =false


alphaSeekBar.maxProgress = 1000
alphaSeekBar.borderColor = Color.BLACK
alphaSeekBar.borderRadius = 10
alphaSeekBar.borderSize = 10
alphaSeekBar.thumbDrawer = DefaultThumbDrawer(30,Color.WHITE,Color.BLUE)
alphaSeekBar.isVertical = false
alphaSeekBar.barHeight = 10
alphaSeekBar.alphaValue = 255 // or alphaSeekBar.progress = 100

Listener

colorSeekBar.setOnColorChangeListener { progress, color ->
    Log.i("TAG", "===progress:$progress-color:$color===")
}

alphaSeekBar.setOnAlphaChangeListener { progress, alpha ->
    Log.i("AlphaSeekBarFragment", "===progress:$progress-alpha:$alpha===")
}

Thumb Drawer

  • com.rtugeek.android.colorseekbar.thumb.DefaultThumbDrawer
  • com.rtugeek.android.colorseekbar.thumb.DrawableThumbDrawer - Load thumb from drawable resource
  • com.rtugeek.android.colorseekbar.thumb.ThumbDrawer - Implement this interface if you want to customize thumb

Vertical Bar

<com.rtugeek.android.colorseekbar.ColorSeekBar 
    android:id="@+id/colorSlider"
    android:layout_width="match_parent" 
    app:colorSeeds="@array/material_colors"
    app:colorSeekBarVertical="true" 
    android:layout_height="wrap_content" />

Spread the word

License

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                Version 2, December 2004

Copyright (C) 2004 Leon Fu <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

 0. You just DO WHAT THE FUCK YOU WANT TO.