Progress step(increment) value
Hello,
Is there any way to set the step value ? I mean if I have values from 0-200 and the step of 25, on stop trackingtouch to get only values multiple of 25 (0, 25, 50, 75...). This is how I temporally implemented on my app :
`circularSeekBar.setOnSeekBarChangeListener(new CircularSeekBar.OnCircularSeekBarChangeListener() { @Override public void onProgressChanged(CircularSeekBar circularSeekBar, int progress, boolean fromUser) { selectedAmount = (progress / 25) * 25; amount.setText(String.valueOf(selectedAmount)); }
@Override
public void onStopTrackingTouch(CircularSeekBar seekBar) {
seekBar.setProgress(selectedAmount);
}
@Override
public void onStartTrackingTouch(CircularSeekBar seekBar) {
}
});
`
Selected amount is an int where I keep the current progress of the seekbar and amount is a textview where I show it. With this implementation I get the values smaller or equal ... so if it's a value inside 25-49 I return 25. It's not the best solution, but it works...
Thanks !
You can do it this way on the onProgressChanged method:
mCircularSeekBar.setOnSeekBarChangeListener(new CircularSeekBar.CircleSeekBarListener() {
@Override
public void onProgressChanged(CircularSeekBar circularSeekBar, int progress, boolean fromUser) {
mCircularSeekBar.setProgress((progress / 10) * 10);
String cardPercentage = String.valueOf(mCircularSeekBar.getProgress()) + " %";
String checkPercentage = String.valueOf(100 - mCircularSeekBar.getProgress()) + " %";
mCardPercentageTextView.setText(cardPercentage);
mCheckPercentageTextView.setText(checkPercentage);
}
@Override
public void onStopTrackingTouch(CircularSeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(CircularSeekBar seekBar) {
}
});
}
Hi @hamz250 ,
Your implementation is exactly like mine. I don't see any improvement (your post looks better because you used the "insert code" function correctly). My question was if there is any way to set the step (the workaround how to apply a function to get it, found it pretty fast). I was looking for a method like "mCircularSeekBar.setStep(step)", like "mCircularSeekBar.setProgress(progress)".
Anyways, thanks for the answer, Have a nice day!