How to make double seekbar in android?

后端 未结 5 1320
旧巷少年郎
旧巷少年郎 2021-02-07 17:55

I am building an android application where the user select the a maximum value by seekbar.

I need another button on the same seekbar so that user can select maximum and

5条回答
  •  悲&欢浪女
    2021-02-07 18:02

    You do not need to use two seekbar , but you can just do the same function of minimum and maximum by using only one seekbar with having two thumbs over it Here its a library you can use https://code.google.com/p/range-seek-bar/

    You can use by using below code

    private final Thumb getClosestThumb(float touchX)
    
    {
    double xValue = screenToNormalized(touchX);        
    return (Math.abs(xValue - normalizedMinValue) < Math.abs(xValue - normalizedMaxValue)) ? Thumb.MIN : Thumb.MAX;
    }
    

    And in the "public boolean onTouchEvent(MotionEvent event)",

    if(pressedThumb == null),
    pressedThumb = getClosestThumb(mDownMotionX);
    

提交回复
热议问题