Slider on my PreferenceScreen

Viewed 40771

I want my preference menu to have something to change the duration of a vibration.

There is no slider tag for prefs.xml, so what is the best way to do this?

8 Answers

If you already moved to androidX you can simply use androidx.preference.SeekBarPreference. Documentation here and here

Define it in XML like this:

<SeekBarPreference
        app:defaultValue="8"
        app:key="COUNT_SPEED"
        app:title="Fast count speed"
        />

enter image description here

Note: Now in Android Studio (my current version is 3.2.1) auto-suggestions doesn't work for androidx.preference.PreferenceScreen in prefs.xml, but don't worry inflating settings from xml with setPreferencesFromResource() works fine. All needed attributes names and component references you can find here.

Related