How can I make Seekbar non touchable?

送分小仙女□ 提交于 2019-12-24 17:45:59

问题


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 ?


回答1:


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.




回答2:


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"



来源:https://stackoverflow.com/questions/15295203/how-can-i-make-seekbar-non-touchable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!