本文介绍了如何使 Seekbar 不可触摸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,我必须使用进度条显示某个级别,但根据设计,这个进度条上也有一个拇指状的圆圈.

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.

所以为了处理焦点并使我的搜索栏foussable = false"&focussableInTouchMode = false",但是我应该怎么做才能使它像进度条一样不可触摸?

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 ?

推荐答案

另一种选择是调用 setOnTouchListener 并使用始终返回 false 的侦听器.请注意,此 UI 会让用户感到困惑,因为您希望搜索栏看起来像一个活动的搜索栏,但行为不像活动的搜索栏.为了 UI 的一致性,使用 setEnabled(false) 更加一致,并且颜色不同是有原因的.

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.

这篇关于如何使 Seekbar 不可触摸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:55