更改进度/ Seekbar标度为非线性(例如对数)

是否有可能将Progress或Seekars的缩放比例改变为非线性?

如果是这样,怎么能改变?

Solutions Collecting From Web of "更改进度/ Seekbar标度为非线性(例如对数)"

例如:

 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. } }); 

反之亦然:

 weightSeekBar.setProgress((int) (Math.sqrt(((userWeight - minWeight) / (maxWeight - minWeight)) * 1000.0f * 1000.0f)));