项目作者: hongbeomi

项目描述 :
📐customizable seekbar with separator
高级语言: Kotlin
项目地址: git://github.com/hongbeomi/DividerSeekBar.git
创建时间: 2020-06-01T03:15:23Z
项目社区:https://github.com/hongbeomi/DividerSeekBar

开源协议:Apache License 2.0

下载


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:

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

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

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


👀 Usage

Basic Example for Kotlin

  1. val dividerSeekBar = DividerSeekBar(this).apply {
  2. max = 100
  3. setTextLocationMode(DividerSeekBar.TEXT_LOCATION_BOTTOM)
  4. setTextInterval(10)
  5. setTextColor(R.color.black)
  6. setTextSize(R.dimen.sp_12)
  7. setSeaLineColor(R.color.light_blue_600)
  8. setSeaLineStrokeWidth(R.dimen.dp_1)
  9. setDividerInterval(10)
  10. setDividerColor(R.color.light_blue_600)
  11. setDividerStrokeWidth(R.dimen.dp_1)
  12. setThumbDefaultDrawable(R.drawable.bg_thumb_default)
  13. setThumbActivatedDrawable(R.drawable.bg_thumb_activated)
  14. setActiveMode(DividerSeekBar.ACTIVE_MODE_TARGET)
  15. setActivateTargetValue(3)
  16. setOnDividerSeekBarChangeStateListener(
  17. object : DividerSeekBar.OnDividerSeekBarChangeStateListener {
  18. override fun onProgressEnabled(dividerSeekBar: DividerSeekBar, progress: Int) {
  19. // do something
  20. }
  21. override fun onProgressDisabled(dividerSeekBar: DividerSeekBar, progress: Int) {
  22. // do something
  23. }
  24. })
  25. }


Text Location, Interval

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

  1. dividerSeekBar.setTextLocationMode(DividerSeekBar.TEXT_LOCATION_BOTTOM) // set text location
  2. 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

  1. dividerSeekBar.setSeaLineColor(R.color.light_blue_600) // set color light_blue_600
  2. 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

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


Thumb Drawable

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

  1. dividerSeekBar.setThumbDefaultDrawable(R.drawable.bg_thumb_default) // set default thumb
  2. 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

  1. dividerSeekBar.setActiveMode(DividerSeekBar.ACTIVE_MODE_TARGET) // set target mode
  2. 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.

  1. dividerSeekBar.setOnDividerSeekBarChangeStateListener(
  2. object : DividerSeekBar.OnDividerSeekBarChangeStateListener {
  3. override fun onProgressEnabled(dividerSeekBar: DividerSeekBar, progress: Int) {
  4. // do something
  5. }
  6. override fun onProgressDisabled(dividerSeekBar: DividerSeekBar, progress: Int) {
  7. // do something
  8. }
  9. }
  10. )


Activate Mode Switch

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

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


XML Attribute

We can set all value in xml

  1. <github.hongbeomi.dividerseekbar.DividerSeekBar
  2. android:id="@+id/dividerSeekBar_test"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:max="100"
  6. app:dividerActiveMode="target"
  7. app:dividerTextLocationMode="top"
  8. app:dividerTextInterval="10"
  9. app:dividerSeaLineStrokeWidth="@dimen/dp_1"
  10. app:dividerSeaLineColor="@color/gray_400"
  11. app:dividerTextColor="@color/gray_600"
  12. app:dividerStrokeWidth="@dimen/dp_1"
  13. app:dividerColor="@color/light_blue_600"
  14. app:dividerTextSize="@dimen/sp_12"
  15. app:dividerActivatedTargetValue="5"
  16. app:dividerThumbActivatedDrawable="@color/thumb_default_enabled_color"
  17. app:dividerThumbDefaultDrawable="@color/thumb_default_disabled_color">
  18. </github.hongbeomi.dividerseekbar.DividerSeekBar>


🌟 Find this project useful?

Support it by joining stargazers for this repository


📝 License

  1. Copyright 2020 Hongbeom Ahn
  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.