How to Set an Android SeekBar to be unmoveable/frozen?

34,226

Solution 1

You need to do this from your activity or fragment by

//java
mySeekBar.setEnabled(false);
//kotlin
mySeekBar.enabled = false;

Or if you want to do it by xml

android:enabled="false"

Solution 2

You could create a subclass whose parent is a SeekBar. In your new class, override the onTouchEvent() method to always return false.

This solution should not "grey out" the seek bar since the enabled state will not change.

Share:
34,226
Rockmaninoff
Author by

Rockmaninoff

Updated on February 02, 2022

Comments

  • Rockmaninoff
    Rockmaninoff over 2 years

    In my XML, I've set the focusable, focusableInTouchMode, clickable, and longClickable variables to false, yet I can still click and move the SeekBar. Do I need to actually change the listener events to do this? That seems so unnecessary.