Convert Figma logo to code with AI

AnderWeb logodiscreteSeekBar

No description available

2,111
401
2,111
75

Top Related Projects

A custom SeekBar on Android, which can be changed the size ,color , thumb drawable , tick drawable , tick text and indicator , also , will show an indicator view with progress above SeekBar when seeking. https://github.com/warkiz/IndicatorSeekBar

 A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)

Quick Overview

The AnderWeb/discreteSeekBar is a custom Android UI component that provides a discrete seek bar, allowing users to select from a predefined set of values instead of a continuous range. This can be useful in scenarios where users need to choose from a specific set of options, such as volume levels or song playback positions.

Pros

  • Customizable Appearance: The library provides a high degree of customization, allowing developers to adjust the appearance of the seek bar to match their app's design.
  • Discrete Value Selection: The seek bar enables users to select from a predefined set of values, providing a more precise and intuitive interaction compared to a continuous seek bar.
  • Smooth Animation: The seek bar transitions smoothly between values, creating a polished and responsive user experience.
  • Lightweight and Efficient: The library is lightweight and efficient, making it suitable for use in performance-critical applications.

Cons

  • Limited Platform Support: The library is designed specifically for Android and may not be suitable for use on other platforms.
  • Dependency on Android SDK: The library relies on the Android SDK, which may limit its portability to other platforms or environments.
  • Potential Learning Curve: Developers who are unfamiliar with custom Android UI components may need to invest time in understanding the library's API and integration process.
  • Lack of Extensive Documentation: The project's documentation, while present, may not be as comprehensive as some developers would prefer.

Code Examples

Here are a few examples of how to use the discreteSeekBar library in your Android project:

  1. Initializing the Seek Bar:
val seekBar = DiscreteSeekBar(context)
seekBar.max = 10
seekBar.progress = 5
  1. Handling Value Changes:
seekBar.setOnProgressChangeListener { value ->
    // Handle the new value
    println("New value: $value")
}
  1. Customizing the Appearance:
seekBar.thumbColor = Color.BLUE
seekBar.progressColor = Color.GREEN
seekBar.indicatorColor = Color.RED
  1. Integrating with Other UI Components:
val layout = LinearLayout(context)
layout.addView(seekBar)

Getting Started

To use the discreteSeekBar library in your Android project, follow these steps:

  1. Add the library to your project's dependencies in your app-level build.gradle file:
dependencies {
    implementation 'com.github.AnderWeb:discreteSeekBar:1.7.4'
}
  1. In your layout XML file, add the DiscreteSeekBar widget:
<com.triggertrap.seekarc.DiscreteSeekBar
    android:id="@+id/seekBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
  1. In your activity or fragment, get a reference to the DiscreteSeekBar and customize its behavior:
val seekBar = findViewById<DiscreteSeekBar>(R.id.seekBar)
seekBar.max = 10
seekBar.progress = 5
seekBar.setOnProgressChangeListener { value ->
    // Handle the new value
    println("New value: $value")
}

That's it! You can now use the discreteSeekBar library in your Android project to provide a custom, discrete seek bar experience for your users.

Competitor Comparisons

A custom SeekBar on Android, which can be changed the size ,color , thumb drawable , tick drawable , tick text and indicator , also , will show an indicator view with progress above SeekBar when seeking. https://github.com/warkiz/IndicatorSeekBar

Pros of IndicatorSeekBar

  • More customization options for the indicator, including various shapes and colors
  • Supports both continuous and discrete modes with configurable step values
  • Offers a wider range of styling options for the thumb and track

Cons of IndicatorSeekBar

  • Larger library size compared to discreteSeekBar
  • May have a steeper learning curve due to more configuration options
  • Less focus on material design principles

Code Comparison

discreteSeekBar:

<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:dsb_min="0"
    app:dsb_max="100"
    app:dsb_value="50" />

IndicatorSeekBar:

<com.warkiz.widget.IndicatorSeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:isb_min="0"
    app:isb_max="100"
    app:isb_progress="50"
    app:isb_show_indicator="true" />

Both libraries provide custom SeekBar implementations for Android, but IndicatorSeekBar offers more extensive customization options at the cost of increased complexity. discreteSeekBar focuses on a simpler, material design-oriented approach, while IndicatorSeekBar provides greater flexibility in appearance and behavior.

 A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)

Pros of RangeSeekBar

  • Supports dual thumb (range) selection
  • Offers more customization options for appearance
  • Includes animation effects for smoother user experience

Cons of RangeSeekBar

  • May have a steeper learning curve due to more complex API
  • Potentially higher resource consumption due to additional features
  • Less focused on discrete values compared to discreteSeekBar

Code Comparison

discreteSeekBar:

<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:dsb_min="0"
    app:dsb_max="100"
    app:dsb_value="50" />

RangeSeekBar:

<com.jaygoo.widget.RangeSeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:rsb_mode="range"
    app:rsb_min="0"
    app:rsb_max="100"
    app:rsb_progress_color="@color/colorAccent" />

Both libraries offer customizable seek bars for Android applications. discreteSeekBar focuses on providing a simple, discrete value selection experience, while RangeSeekBar offers more advanced features like range selection and extensive customization options. The choice between the two depends on the specific requirements of your project and the level of complexity you're willing to work with.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

#DiscreteSeekBar

screenshot

screenshot

DiscreteSeekbar is my poor attempt to develop an android implementation of the Discrete Slider component from the Google Material Design Guidelines.

##Prologe I really hope Google provides developers with a better (and official) implementation ;)

##Warning After a bunch of hours trying to replicate the exact feel of the Material's Discrete Seekbar, with a beautiful stuff-that-morphs-into-other-stuff animation I was convinced about releasing the current code.

android.util.Log.wtf("WARNING!! HACKERY-DRAGONS!!");

I've done a few bit of hacky cede and a bunch of things I'm not completely proud of, so use under your sole responsibility (or help me improve it via pull-requests!)

##Implementation details This thing runs on minSDK=7 (well, technically could run 4 but can't test since AVDs for api 4 are deprecated and just don't boot). Obviously some of the subtle animations (navigating with the Keyboard, the Ripple effect, text fade ins/fade outs, etc) are not going to work on APIS lower than 11, but the bubble thing does. And I haven't found a way of improving this with 11-21 APIs, so...

The base SeekBar is pretty simple. Just 3 drawables for the track, progress and thumb. Some touch event logic to drag, some key event logic to move, and that's all.

It supports custom ranges (custom min/max), even for negative values.

The bubble thing DOESN'T USE VectorDrawableMagic . I was not really needed for such a simple morph. It uses instead an Animatable Drawable for the animation with a lot of hackery for callbacks, drawing and a bunch of old simple math.

For this to work (and sync with events, etc) I've written a fair amount of shit questionable code...

The material-floating-thing is composed into the WindowManager (like the typical overflow menus) to be able to show it over other Views without needing to set the SeekBar big enough to account for the (variable) size of he floating thing.

For this I'm not sure about the amounts of things I've copied from PopupWindow and the possible issues.

##Dependencies It uses com.android.support:support-v4 as the only dependency.

##Usage This is published in jCenter so you need to use the appropiate repo:

repositories {
    jcenter()
}

dependencies {
    compile 'org.adw.library:discrete-seekbar:1.0.1'
}

Once imported into your project, you just need to put them into your layous like:

<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:dsb_min="2"
        app:dsb_max="15"
/>

####Parameters You can tweak a few things of the DiscreteSeekbar:

  • dsb_min: minimum value
  • dsb_max: maximum value
  • dsb_value: current value
  • dsb_mirrorForRtl: reverse the DiscreteSeekBar for RTL locales
  • dsb_allowTrackClickToDrag: allows clicking outside the thumb circle to initiate drag. Default TRUE
  • dsb_indicatorFormatter: a string Format to apply to the value inside the bubble indicator.
  • dsb_indicatorPopupEnabled: choose if the bubble indicator will be shown. Default TRUE

####Design

  • dsb_progressColor: color/colorStateList for the progress bar and thumb drawable
  • dsb_trackColor: color/colorStateList for the track drawable
  • dsb_indicatorTextAppearance: TextAppearance for the bubble indicator
  • dsb_indicatorColor: color/colorStateList for the bubble shaped drawable
  • dsb_indicatorElevation: related to android:elevation. Will only be used on API level 21+
  • dsb_rippleColor: color/colorStateList for the ripple drawable seen when pressing the thumb. (Yes, it does a kind of "ripple" on API levels lower than 21 and a real RippleDrawable for 21+.
  • dsb_trackHeight: dimension for the height of the track drawable.
  • dsb_scrubberHeight: dimension for the height of the scrubber (selected area) drawable.
  • dsb_thumbSize: dimension for the size of the thumb drawable.
  • dsb_indicatorSeparation: dimension for the vertical distance from the thumb to the indicator.

You can also use the attribute discreteSeekBarStyle on your themes with a custom Style to be applied to all the DiscreteSeekBars on your app/activity/fragment/whatever.

##License

Copyright 2014 Gustavo Claramunt (Ander Webbs)

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.