简体   繁体   中英

How can I make Seekbar non touchable?

I have scenario where I have to show some level using a progress bar, but according to the design this progress bar has a thumb like circle on it too.

Now the user is not supposed to change the value of this bar either by touch or by using keys.

The 'thumb' is available in Seek bar but not in Progress bar, but Seek bar is capable of taking focus and touch events, while this should not happen in my case.

So for handling the focus and make my seek bar "foussable = false" & "focussableInTouchMode = false", but what should I do to make it non-touchable almost like a progress bar ?

Another option is to call setOnTouchListener and use a listener that always returns false. Note that this UI is confusing to users as you want the seekbar to look like an active one, but not behave like an active seekbar. For UI consistency, using setEnabled(false) is more consistent, and the colors are different for a good reason.

what you can do is, create custom seekbarwith following two property, and call enable(false)

android:progressDrawable="@drawable/progress_bar"

android:thumb="@android:color/transparent" // to make thumb invisible

and then call for runtime

SeekBar.setEnabled(false)

and from xml

android:enabled="false"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM