如何调整 Android SeekBar 灵敏度
我第一次尝试使用 SeekBar,但对结果感到失望。我有一个应用程序需要使用滑块来覆盖 80 个点。我希望用户能够以 0.5 的增量移动(即 10.5、11.0)。我的最大范围是 40,这就是为什么我将其加倍到 80 以考虑小数。
一切正常,但当我把它放在我的 Droid 上时,我认为性能很糟糕。当试图停在 21.5 时,滑块通常会停在 22.0 或 22.5 处,我不得不花额外的时间来尝试将其缓慢移动。其他时候,我会尝试选择滑块,但它没有响应。我并不担心无响应,但如果它要求用户精确地到达某个位置,我就不能将 SeekBar 放入我的应用程序中。
我可以做些什么来调整 SeekBar,以便轻松地找到您想要登陆的数字吗?我不确定问题是否发生,因为我的 SeekBar 包含大量可能的值,并且由于屏幕尺寸有限,这会迫使数字被挤得更近?或者如果这只是它的一般行为方式。
如果没有调整灵敏度的好方法,是否有一个可以提供类似功能的好替代方案?
I attempted to use a SeekBar for the first time, and I was disappointed with the results. I have an app that needs to use a slider to cover 80 spots. I want the user to be able to move in .5 increments (i.e. 10.5, 11.0). My max range is 40, which is why I doubled it to 80 to account for the decimals.
Everything worked, but when I put it on my Droid, the performance was terrible in my opinion. When trying to stop on 21.5, the slider usually stopped at 22.0 or 22.5, and I had to take extra time to try and inch it over. Other times I would try to select the slider and it was unresponsive. I'm not as concerned about the unresponsiveness, but I can not put the SeekBar in my app if it requires the user to have exact precision to hit a certain spot.
Is there anything that I can do to adjust the SeekBar so that it is easy to hit the number you are trying to land on without difficulty? I'm not sure if the problem is occurring because my SeekBar contains a large amount of possible values, and with screen size limited this forces the numbers to be smashed closer together? Or if this is just the way it behaves in general.
If there isn't a good way to adjust the sensitivity, is there a good alternative that I can use that provides similar functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有完全相同的问题,并想出了自己的降低敏感度的方法。对我来说,问题发生在我离开滑块时,由于手指粗细等原因,滑块无意中被重新定位。因此,我编写了一个计时器来查看该位置是否已选择一段时间,然后捕捉到此位置离开搜索栏时的位置。这种方法有点笨拙,但这是我能想到的最好的方法,因为我不想要上面建议的 +/- 按钮。它很适合我的需要。这是任何有兴趣的人的代码:
I have the exact same problem and came up with my own way of reducing the sensitivity. The problem for me happens when I am leaving the slider and it unintentionally gets repositioned, because of thickness of fingers etc. So I wrote a timer to see if the position was selected for a while and snap to this position while leaving the seekbar. This method is a bit clumsy but this is the best I can think of, given I do not want +/- buttons as suggested above. It works well for my needs. Here is the code for anyone interested:
差不多就是这个了。您可以做的一件事是在搜索栏旁边添加一个小加号和减号按钮,该按钮可将值增加或减少 0.5。这样,您仍然可以在一般情况下使用搜索栏,并在需要时使用按钮优化您的选择。也许不是最优雅的解决方案,但它肯定会起作用。
Pretty much this. One thing you could do is add a small plus and minus button beside the seekbar, which increment and decrement the value by 0.5. This way you could still use the seekbar for general cases, and refine your selection with the buttons if needed. Maybe not the most elegant solution, but it would certainly work.