DiscreteSeekBar


Source link: https://github.com/AnderWeb/discreteSeekBar

#DiscreteSeekBar

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. 

Resources

This is an event bus designed to allowing your application to communicate efficiently.

RxAndroidBle is a powerful painkiller for Android's Bluetooth Low Energy headaches. It is backed by RxJava, implementing complicated APIs as handy reactive observables.

Utils to work with Status Bar.

Simple Reactive wrapper for Android sensors.

Welcome Coordinator is a library for Android that helps you to create really awesome welcome wizards for your Apps, but this is not all, also you can use the library to create form wizards really nice.

A Beautiful Material color picker view for Android.

Identical remake of Chroma in Java instead of Kotlin, so it is much more lightweight for using in kotlin-less apps.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes