Android Seekbar 有两个拇指
这个问题的变体可以在互联网上找到,但没有答案。
我想要一个带有两个拇指范围选择的搜索栏。我愿意自己编程,但缺乏 Android 经验。有人可以给我一些关于从哪里开始的指示吗?我的意思是,我知道我必须扩展一些东西(可能是进度条),但是我应该如何去做呢?我真的必须重新创建标准搜索栏的所有功能吗?还是有更简单的方法?
当然,也欢迎完整的解决方案;)
Variations of this question can be found all over the internet but not an answer.
I want a seekbar with two-thumb range selection. I'm willing to program this myself but I lack experience with Android. Could someone give me some pointers on where to start. I mean, I know I will have to extend something (ProgressBar probably), but how should I go about to do that? Do I really have to recreate all the functionality of a standard seekbar, or is there an easier way?
Complete solutions are also welcome of course ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我也一直在找这个,没有结果。所以我制作了一个新的小部件,请随意使用它: https://github.com/ anothem/android-range-seek-bar
I too was looking for this, to no avail. So I made a new widget, feel free to use it: https://github.com/anothem/android-range-seek-bar
“我也在寻找这个,但没有成功。所以我制作了一个新的小部件,请随意使用它: https://code.google.com/p/range-seek-bar/”
Stephan 链接的这个示例效果非常好!
然而,用户必须按下任意拇指才能获得响应。我希望如果用户按下该栏,最近的拇指就会移动到该位置并像平常一样工作。
我在示例代码中实现了这一点,如下所示:
在“
public boolean onTouchEvent(MotionEvent event)
”中,"I too was looking for this, to no avail. So I made a new widget, feel free to use it: https://code.google.com/p/range-seek-bar/"
This example Stephan linked works great!
However, the user has to press any of the thumbs to get a respons. I wanted that if the user pressed the bar, the closest thumb would move to that position and work like normal.
I implemented this in the example code like this:
And in the "
public boolean onTouchEvent(MotionEvent event)
",带有左右图标的窗口搜索栏。
可预设最小窗口大小和自动防交叉。
Mercurial 存储库位于 https://bitbucket.org/nimbusgb/windowed-seek-bar
A windowed seek bar with left and right icons.
Presettable minimum window size and automatic anti crossover.
Mercurial repository at https://bitbucket.org/nimbusgb/windowed-seek-bar
我使用了 anothem/android-range-seek-bar 库
https://github.com /anothem/android-range-seek-bar
在 xml 中
I have used the anothem/android-range-seek-bar library
https://github.com/anothem/android-range-seek-bar
In xml
如果您正在使用任何材料组件,例如:Snackbar、BottomNavigationView 等,则不必使用其他第 3 方库。
材质库还附带 RangeSlider,它可以用于选择一个值范围。
材质库 - 实现“com.google.android.material:material:latestVersion”
Incase you are using any of the material components such as:
Snackbar, BottomNavigationView
etc. you don't have to use another 3rd party library.The material library also ships with RangeSlider which can be used to select a range of values.
Material library - implementation 'com.google.android.material:material:latestVersion'