Double handled slider android [closed]

寵の児 提交于 2019-12-03 04:24:01

问题


I was wondering if anyone had some code, or knew of a place that has code for creating a double handled slider. Example :

I am looking to do something similar using a double slider to search for a range of ages on a time array , like in the photo

Thanks in advance


回答1:


I managed to build it myself... the idea I followed was different from the answers above. I created some items that can be dragged on the screen with the finger, and I fixed the Y position so it can only move from left to right. After that, I generated rectangles that signify the progress (between knobs and outside them). The good thing about this technique is that you can easily customize the slider to be vertical or horizontal, or if you want to put a custom picture in the background. The source is in the link below, and if anyone has any questions please ask. link: eclipse project




回答2:


Have you seen the range-seek-bar. It looks like it would work perfectly.!




回答3:


You could try and extend the AbsSeekBar and have a look at the single-thumbed-SeekBar how it works.




回答4:


I have looked through the entire Widgets package and incredibly, the ADT doesn't have any slider control! This obviously puts you at a serious disadvantage since there is nothing already implemented for you to extend or modify.

However, there is this guide on hacking together a custom slider component out of a ProgressBar component. This might be your solution. The author overrides the onTouchEvent method to set the progress bar's value according to the touch coordinates. Very clever. However, since a progress bar can only show one value, it's only possible to show the lower or upper bound using a single progress bar.

My suggestion is to create a compound component which has one progress bar that is always at 0%, and another progress bar which is always at 100%. The second bar is overlaid on top of the first one, and its coordinates and width set so its left edge represents the lower bound (x), and the right edge shows the upper bound (x + width). Your onTouchEvent will detect whether the touch coordinates are closer to the lower or upper bound, and then start adjusting that bound until released. When the bounds change, you simply reposition and resize the second bar. Provided you can position components absolutely and on top of other components, this should look great!



来源:https://stackoverflow.com/questions/5606121/double-handled-slider-android

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