Skip to content

hongbeomi/DividerSeekBar

Repository files navigation

DividerSeekBar

📐 customizable seekbar with separator.


🚀 how to include to your project?

license android CI api

Gradle

Add it in your root build.gradle at the end of repositories:

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

And add a this code to your module's build.gradle file.

dependencies {
    implementation 'com.github.hongbeomi:DividerSeekBar:v1.0.3'
}

👀 Usage

Basic Example for Kotlin

val dividerSeekBar = DividerSeekBar(this).apply {
  max = 100
  setTextLocationMode(DividerSeekBar.TEXT_LOCATION_BOTTOM)
  setTextInterval(10)
  setTextColor(R.color.black)
  setTextSize(R.dimen.sp_12)
  setSeaLineColor(R.color.light_blue_600)
  setSeaLineStrokeWidth(R.dimen.dp_1)
  setDividerInterval(10)
  setDividerColor(R.color.light_blue_600)
  setDividerStrokeWidth(R.dimen.dp_1)
  setThumbDefaultDrawable(R.drawable.bg_thumb_default)
  setThumbActivatedDrawable(R.drawable.bg_thumb_activated)
  setActiveMode(DividerSeekBar.ACTIVE_MODE_TARGET)
  setActivateTargetValue(3)
  setOnDividerSeekBarChangeStateListener(
    object : DividerSeekBar.OnDividerSeekBarChangeStateListener {
      override fun onProgressEnabled(dividerSeekBar: DividerSeekBar, progress: Int) {
      // do something
      }
      override fun onProgressDisabled(dividerSeekBar: DividerSeekBar, progress: Int) {
      // do something
      }
    })
}

Text Location, Interval

We can set text location mode and interval. Default interval value is 1

dividerSeekBar.setTextLocationMode(DividerSeekBar.TEXT_LOCATION_BOTTOM) // set text location
dividerSeekBar.setTextInterval(10) // set text interval of divider 
Location: BOTTOM
TEXT_LOCATION_BOTTOM
Location: TOP
TEXT_LOCATION_TOP

SeaLine Color, Stroke Width

We can change SeaLine color and stroke width

dividerSeekBar.setSeaLineColor(R.color.light_blue_600) // set color light_blue_600 
dividerSeekBar.setSeaLineStrokeWidth(R.dimen.dp_1) // set width 1dp

Divider Color, Stroke Width, Interval

We can change the color and stroke width, interval of the divider. default divider interval value is 1

dividerSeekBar.setDividerInterval(10) // set divider interval 10
dividerSeekBar.setDividerColor(R.color.light_blue_600) // set color light_blue_600
dividerSeekBar.setDividerStrokeWidth(R.dimen.dp_1) // set width 1dp

Thumb Drawable

We can change Thumb when Activated and when Default (Not Activated).

dividerSeekBar.setThumbDefaultDrawable(R.drawable.bg_thumb_default) // set default thumb
dividerSeekBar.setThumbActivatedDrawable(R.drawable.bg_thumb_activated) // set activated thumb

Activated Mode & Target Value

We can set activated mode, target value. default mode is ACTIVE_MODE_MINIMUM, default target value is 0

dividerSeekBar.setActiveMode(DividerSeekBar.ACTIVE_MODE_TARGET) // set target mode
dividerSeekBar.setActivateTargetValue(3) // set target value
Mode : ACTIVE_MODE_TARGET
TargetValue : 3
Mode : ACTIVE_MODE_MINIMUM
TargetValue : 3
Mode : ACTIVE_MODE_MAXIMUM
TargetValue : 3

onProgressEnabled, onProgressDisabled

We can hear DividerSeekBar when it is active and when it is not active, and we can listen it using the listener.

dividerSeekBar.setOnDividerSeekBarChangeStateListener(
  object : DividerSeekBar.OnDividerSeekBarChangeStateListener {
    override fun onProgressEnabled(dividerSeekBar: DividerSeekBar, progress: Int) {
    // do something
    }
    override fun onProgressDisabled(dividerSeekBar: DividerSeekBar, progress: Int) {
    // do something
    }
  }
)

Activate Mode Switch

We can Activate mode turn it on and off. default is on status

dividerSeekBar.setOffActivatedEvent() // set off
dividerSeekBar.setOnActivatedEvent() // set on

XML Attribute

We can set all value in xml

<github.hongbeomi.dividerseekbar.DividerSeekBar
        android:id="@+id/dividerSeekBar_test"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="100"
        app:dividerActiveMode="target"
        app:dividerTextLocationMode="top"
        app:dividerTextInterval="10"
        app:dividerSeaLineStrokeWidth="@dimen/dp_1"
        app:dividerSeaLineColor="@color/gray_400"
        app:dividerTextColor="@color/gray_600"
        app:dividerStrokeWidth="@dimen/dp_1"
        app:dividerColor="@color/light_blue_600"
        app:dividerTextSize="@dimen/sp_12"
        app:dividerActivatedTargetValue="5"
        app:dividerThumbActivatedDrawable="@color/thumb_default_enabled_color"
        app:dividerThumbDefaultDrawable="@color/thumb_default_disabled_color">
</github.hongbeomi.dividerseekbar.DividerSeekBar>

🌟 Find this project useful?

Support it by joining stargazers for this repository


📝 License

Copyright 2020 Hongbeom Ahn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

			http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.