https://github.com/siavash79/rangesliderpreference
Android Preference based on RangeSlider
https://github.com/siavash79/rangesliderpreference
android library preference range slider
Last synced: about 1 year ago
JSON representation
Android Preference based on RangeSlider
- Host: GitHub
- URL: https://github.com/siavash79/rangesliderpreference
- Owner: siavash79
- License: gpl-3.0
- Created: 2022-07-03T03:14:30.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-15T14:10:06.000Z (over 1 year ago)
- Last Synced: 2025-04-15T06:08:18.666Z (about 1 year ago)
- Topics: android, library, preference, range, slider
- Language: Java
- Homepage:
- Size: 91.8 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Range Slider Preference
This is a simple (yet very useful) library, based on com.google.android.material.slider.RangeSlider widget, to be used as Preference in Android's PreferenceScreen pages.
**The problem:**
Android's built-in SeekBarPreference can only include a single slider, thus can show/set only one value per preference. However, if you need to set ranges in preferences, there's no built-in Slider Preference available.
**Range Slider Preference** is able to show/set several values per preference, covering SeekBarPreference's shortcoming.
**How to include**
You can clone this repository using git, or simply add it to your project as a submodule (git submodule add https://github.com/siavash79/rangesliderpreference.git)
To use this preference in your apps, simply add this repository to your project as a module, and add the module to your app's dependencies.
You can then add it as a preference to your app settings page:
.
.
.
.
In the above example, you are setting a slider that operates 3 values that must be between 0 to 60, increase every 0.5 unit, and if the preference is not yet set, defaults to 3, 12 and 46.5.
RangeSliderPreference is also able to parse the values of your previously-set preference, if it's of any of types Integer, Float, or JSON string (Name/value, or name/array)
to read the preference values in your app, simply use the static method included:
List values = RangeSliderPreference.getValues(
myPrefrences /*SharedPreferences*/,
"MY_KEY" /* preference key */,
2 /* default value in case the preference was not found */);
and the value(s) will be presented in a List\ object.