Is it possible to change the scaling of Progress- or Seekbars to be non-linear?
If so, how can it be changed?
For example:
weightSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
// place onStartTrackingTouch(SeekBar seekBar) and onStopTrackingTouch(SeekBar seekBar) here
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
userWeight = ((progress * progress) / (1000.0f * 1000.0f)) * (maxWeight - minWeight) + minWeight; // Approximate an exponential curve with x^2.
}
});
and vice versa:
weightSeekBar.setProgress((int) (Math.sqrt(((userWeight - minWeight) / (maxWeight - minWeight)) * 1000.0f * 1000.0f)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With