How to make double seekbar in android?

后端 未结 5 1327
旧巷少年郎
旧巷少年郎 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 17:58

    RangeSeekBar https://github.com/RanaRanvijaySingh/RangeSeekBar. Also there are other libraries available which offers a lot of customization. If you want to go for more interactive design then look for Material Range Bar http://android-arsenal.com/details/1/1272.

    0 讨论(0)
  • 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);
    
    0 讨论(0)
  • 2021-02-07 18:02

    Fully Customize two way and single way seek bar you can provide thumb color etc http://codingsignals.com/crystal-range-seekbar-in-android/

    Add in your gradle

    dependencies {
    compile 'com.crystal:crystalrangeseekbar:1.0.0' 
    }
    

    <com.crystal.crystalrangeseekbar.widgets.BubbleThumbRangeSeekbar
    android:id="@+id/rangeSeekbar5"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:corner_radius="10"
    app:min_value="0"
    app:max_value="100"
    app:steps="5"
    app:bar_color="#F7BB88"
    app:bar_highlight_color="#E07416"
    app:left_thumb_image="@drawable/thumb"
    app:right_thumb_image="@drawable/thumb"
    app:left_thumb_image_pressed="@drawable/thumb_pressed"
    app:right_thumb_image_pressed="@drawable/thumb_pressed"
    app:data_type="_integer"/>
    
    0 讨论(0)
  • 2021-02-07 18:09

    From Here

            <com.appyvet.rangebar.RangeBar
                xmlns:custom="http://schemas.android.com/apk/res-auto"
                android:id="@+id/SearchrangeSeekbarAge"
                android:layout_width="match_parent"
                android:layout_height="72dp"
                custom:tickStart="18"
                custom:tickInterval="1"
                custom:tickEnd="70" />
    
    
            <com.appyvet.rangebar.RangeBar
                xmlns:custom="http://schemas.android.com/apk/res-auto"
                android:id="@+id/SearchrangeSeekbarHeight"
                android:layout_width="match_parent"
                android:layout_height="72dp"
                custom:tickStart="4.5"
                custom:tickInterval="0.10"
                custom:tickEnd="7.0" />
    
    
    rangebar.setOnRangeBarChangeListener(new RangeBar.OnRangeBarChangeListener() {
            @Override
            public void onRangeChangeListener(RangeBar rangeBar, int leftPinIndex,
                    int rightPinIndex,
                    String leftPinValue, String rightPinValue) {
            }
        });
    
    0 讨论(0)
  • 2021-02-07 18:19

    The Android widget class library has only one slider control, seekbar with only one thumb control. Did some research online and found this cool custom widget, range-seek-bar.

    you can followed any one of below

    https://github.com/edmodo/range-bar

    https://code.google.com/p/range-seek-bar/

    https://github.com/Larpon/RangeSeekBar

    0 讨论(0)
提交回复
热议问题