syedowaisali / crystal-range-seekbar

537 stars 164 forks source link

Can't able to set min & max start value to max limit? #139

Open appukrb opened 5 years ago

appukrb commented 5 years ago

My crystal seek bar is from 0 to 1000 and I can't able to set min & max start value to 1000.

final CrystalRangeSeekbar seekbar = findViewById(R.id.rangeSeekbar5); long min=0,max = 10; seekbar.setMaxValue(max); seekbar.setMinValue(min); long val = 10; seekbar.setMaxStartValue(val); seekbar.setMinStartValue(val); seekbar.apply();

A86S commented 5 years ago

its working while i did via programmatically and remove the max, min from xml

ageRangeSeekBar.setMaxValue(70F)
ageRangeSeekBar.setMinValue(18F)

ageRangeSeekBar.setMaxStartValue(70F)
ageRangeSeekBar.setMinStartValue(18F)
**ageRangeSeekBar.apply()**

i think the issue with long values, above functions is taking float value.

H4zh4n commented 4 years ago

An age later, I seem to have the same issue, I was wondering if any of you found a work-around. I tried removing min-max from xml as suggested by @A86S, still same.

H4zh4n commented 4 years ago

I found a work-around. For future person who gets the same issue, what I did was I negated setMinStartValue by a small amount (anything less than 0.5f), this caused it to still be on the same number but different as well, it also moves the thumb to left a little bit which is kinda nice.

what my final code looks like:

rng.setMinStartValue(value - 0.3f); rng.setMaxStartValue(value);

The variable (value) is Integer, which does not affect my output. If your number is float maybe try to negate by an amount that would not affect your work (say 0.000001f)