syedowaisali / crystal-range-seekbar

537 stars 164 forks source link

CrystalRangeSeekbar min/max and current values #150

Open gaminn opened 4 years ago

gaminn commented 4 years ago

I tried this sample code:

<com.crystal.crystalrangeseekbar.widgets.CrystalRangeSeekbar
    android:id="@+id/rangeSeekbar3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:corner_radius="10"
    app:min_value="50"
    app:max_value="100"
    app:gap="20"
    app:bar_color="#8990C4"
    app:bar_highlight_color="#2434AD"
    app:left_thumb_color="#1A246D"
    app:right_thumb_color="#1A246D"
    app:left_thumb_color_pressed="#030B47"
    app:right_thumb_color_pressed="#030B47"
    app:data_type="_integer"/>

As shown on the initial page of this repo this should display blue range seekbar with current values displayed on the sides. However, in my app, it doesn't display current values.

How to show current values near the seekbar? Or preferably moving labels under the thumb (I know I can implement moving text myself using onRangeSeekbarChangeListener but imagine a situation where the seekbar min and max are 0 - 10 with granularity of 1 and the seekbar is 500 px wide - the moving labels would jump, they won't move smoothly)?

How to show min and max values of the seekbar near the seekbar?

mohamedtourab commented 4 years ago

The text that appears in the example are TextViews that are added manually, then you can override the setOnRangeSeekbarChangeListener and change the values of the textviews . This is from the examples provided in the readme


rangeSeekbar.setOnRangeSeekbarChangeListener(new OnRangeSeekbarChangeListener() {
    @Override
    public void valueChanged(Number minValue, Number maxValue) {
        tvMin.setText(String.valueOf(minValue));
        tvMax.setText(String.valueOf(maxValue));
    }
});