All Projects → hearsilent → Discreteslider

hearsilent / Discreteslider

Licence: mit
A slider (SeekBar) with amazing value label.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Discreteslider

Multislider
Multi functional slider/seekbar( / rangebar / scrubber) for Android
Stars: ✭ 309 (-11.97%)
Mutual labels:  slider, seekbar
Emojislider
🤯 A slider widget rich in emoji and highly customisable.
Stars: ✭ 549 (+56.41%)
Mutual labels:  slider, seekbar
Rangeseekbar
A beautiful and powerful SeekBar what supports single、 range、steps、vetical、custom( 一款美观强大的支持单向、双向范围选择、分步、垂直、高度自定义的SeekBar)
Stars: ✭ 2,037 (+480.34%)
Mutual labels:  slider, seekbar
jekyll-ideal-image-slider-include
Add image sliders to Jekyll with Ideal Image Slider. HTML include version. Github Pages compatible. (This repository is archived. Issues are disabled. Pull requests will be ignored.)
Stars: ✭ 27 (-92.31%)
Mutual labels:  slider
react-styled-carousel
React styled components carousel or slide show. No external css import is required.
Stars: ✭ 42 (-88.03%)
Mutual labels:  slider
Swagpoints
An Android custom circular SeekBar that supports max/min range and step settings.
Stars: ✭ 300 (-14.53%)
Mutual labels:  seekbar
Sectionedslider
iOS 11 Control Center Slider
Stars: ✭ 336 (-4.27%)
Mutual labels:  slider
rn-circular-slider
React Native circular slider based on react-native-svg
Stars: ✭ 25 (-92.88%)
Mutual labels:  slider
Zuck.js
A javascript library that lets you add stories EVERYWHERE.
Stars: ✭ 3,396 (+867.52%)
Mutual labels:  slider
Slidepage
简单、跨平台、无依赖的全屏滚动H5插件,可实现内容超出屏幕滚动、动态更新等特色功能
Stars: ✭ 285 (-18.8%)
Mutual labels:  slider
Bootstrap Slider
A slider control for Bootstrap 3 & 4.
Stars: ✭ 2,981 (+749.29%)
Mutual labels:  slider
Ngx Slider
Self-contained, mobile friendly slider component for Angular 6+ based on angularjs-slider
Stars: ✭ 258 (-26.5%)
Mutual labels:  slider
React Native Paper Onboarding
Paper Onboarding is a material design UI slider for `React Native`.
Stars: ✭ 310 (-11.68%)
Mutual labels:  slider
Bubbleseekbar
A beautiful Android custom seekbar, which has a bubble view with progress appearing upon when seeking. 自定义SeekBar,进度变化更以可视化气泡样式呈现
Stars: ✭ 3,036 (+764.96%)
Mutual labels:  seekbar
SlidableImage
Fancy slider for before&after images
Stars: ✭ 32 (-90.88%)
Mutual labels:  slider
Circular Slider Android
Circular Slider UI Control for Android
Stars: ✭ 315 (-10.26%)
Mutual labels:  slider
zSlider
A pure JavaScript Carousel/Slider plugin that works well at Mobile/PC
Stars: ✭ 12 (-96.58%)
Mutual labels:  slider
Sleek circular slider
Sleek circular slider for Flutter
Stars: ✭ 269 (-23.36%)
Mutual labels:  slider
Skitter
Skitter - Slideshow for anytime
Stars: ✭ 295 (-15.95%)
Mutual labels:  slider
Vue Flickity
A Vue Slider / Carousel Component for Flickity.js
Stars: ✭ 339 (-3.42%)
Mutual labels:  slider

DiscreteSlider

JitPack license

DiscreteSlider tries to offer you the slider with value label as shown in the Material Design spec, with an API. The library also offer you range slider mode.

Screenshot

Normal Mode

Range Mode

Vertical Orientation

Setup

The easiest way to add the DiscreteSlider library to your project is by adding it as a dependency to your build.gradle

Step 1. Add the JitPack repository to your build file

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

Step 2. Add the dependency

dependencies {
    implementation 'com.github.hearsilent:DiscreteSlider:1.2.1'
}

Usage

Setup Track in Java

mSlider.setTrackWidth(Utils.convertDpToPixel(4, this));
mSlider.setTrackColor(0xFFD81B60);
mSlider.setInactiveTrackColor(0x3DD81B60);

Setup Track in Xml

app:ds_trackWidth="4dp"
app:ds_trackColor="#D81B60"
app:ds_inactiveTrackColor="#3DD81B60"

Setup Thumb in Java

mSlider.setThumbRadius(Utils.convertDpToPixel(6, this));
mSlider.setThumbColor(0xFFD81B60);
mSlider.setThumbPressedColor(0x1FD81B60);

Setup Thumb in Xml

app:ds_thumbRadius="6dp"
app:ds_thumbColor="#D81B60"
app:ds_thumbPressedColor="#1FD81B60"

Setup TickMark in Java

mSlider.setTickMarkColor(0x3DFFFFFF);
mSlider.setTickMarkInactiveColor(0x1FD81B60);
mSlider.setTickMarkPatterns(Arrays.asList(new Dot(), new Dash(Utils.convertDpToPixel(1, this))));
// TickMark step must be a factor of (count - 1)
mSlider.setTickMarkStep(1);

Setup TickMark in Xml

app:ds_tickMarkColor="#3DFFFFFF"
app:ds_tickMarkInactiveColor="#1FD81B60"
<!-- Separated by commas, only accept `dot` or `dash`. You can also fill in "dot,dash,dash" -->
app:ds_tickMarkPatterns="dot,dash"
app:ds_tickMarkDashLength="1dp"
<!-- TickMark step must be a factor of (count - 1) -->
app:ds_tickMarkStep="1"

Setup ValueLabel in Java

mSlider.setValueLabelTextColor(Color.WHITE);
mSlider.setValueLabelTextSize(Utils.convertSpToPixel(16, this));
mSlider.setValueLabelGravity(DiscreteSlider.TOP);
// Customize value label's text by `setValueLabelFormatter`
mSlider.setValueLabelFormatter(new DiscreteSlider.ValueLabelFormatter() {

    @Override
    public String getLabel(int input) {
        return Integer.toString(input);
    }
});
mSlider.setValueLabelMode(1); // 0: none, 1: showOnPressHold, 2: showOnProgressChange, 3: showOnPressHold & showOnProgressChange
mSlider.setValueLabelDuration(1500); // Use for mode `showOnProgressChange`

Setup ValueLabel in Xml

app:ds_valueLabelTextColor="#FFF"
app:ds_valueLabelTextSize="16sp"
app:ds_valueLabelGravity="top"
app:ds_valueLabelMode="showOnPressHold|showOnProgressChange" <!-- Default is showOnPressHold -->
app:ds_valueLabelDuration="2500" <!-- Default is 1500ms -->

Setup Progress in Java

mSlider.setCount(21);
mSlider.setProgressOffset(10);
mSlider.setProgress(5); // The same as `setMinProgress`.
mSlider.setMinProgress(5);
mSlider.setMaxProgress(10); // Only can call in range mode.

Setup Progress in Xml

app:ds_count="21"
app:ds_progressOffset="10"
app:ds_minProgress="5"
app:ds_maxProgress="5"

Get Progress in Java

mSlider.getProgress(); // The same as `getMinProgress`.
mSlider.getMinProgress();
mSlider.getMaxProgress();
mSlider.setValueChangedImmediately(true); // Default is false
mSlider.setOnValueChangedListener(new DiscreteSlider.OnValueChangedListener() {

    @Override
    public void onValueChanged(int progress, boolean fromUser) {
        super.onValueChanged(progress, fromUser);
        Log.i("DiscreteSlider", "Progress: " + progress + ", fromUser: " + fromUser);
    }

    @Override
    public void onValueChanged(int minProgress, int maxProgress, boolean fromUser) {
        super.onValueChanged(minProgress, maxProgress, fromUser);
        Log.i("DiscreteSlider",
                "MinProgress: " + minProgress + ", MaxProgress: " + maxProgress +
                        ", fromUser: " + fromUser);
    }
});

Setup Mode in Java

mSlider.setMode(DiscreteSlider.MODE_RANGE);

Setup Mode in Xml

app:ds_mode="range"

Setup Click to Move in Java (By default is false)

mSlider.setClickable(true);

Setup Click to Move in Xml (By default is false)

android:clickable="true"
android:focusable="true"

Setup Orientation in Xml (By default is horizontal)

app:ds_orientation="vertical"

Setup HapticFeedback in Java (By default is Enabled)

mSlider.setHapticFeedbackEnabled(false);

Customize

You can draw thumb as you want.

public class CustomDiscreteSlider extends DiscreteSlider {

    @Override
    public void onDrawThumb(Canvas canvas, float cx, float cy, boolean hasTouched) {
        // Draw thumb as you want
    }

    @Override
    public int getSize() {
        // Override this value to your thumb size
        return super.getSize();
    }
}

Notice

Must set clipChildren to false in parent layout.

Compatibility

Android ICE CREAM SANDWICH 4.0+

Credits

This project was inspired by the Material Design spec by Google.

License

MIT License

Copyright (c) 2019 HearSilent

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].