Java – how do I reverse the seekbar value?
•
Java
I have the following code:
int min = 1; int max = 255; seekBar.setMax(max - min); seekBar.setOnSeekBarchangelistener(new SeekBar.OnSeekBarchangelistener() { @Override public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser) { int value = progress + min; } });
Values: 1... 255
The value I want: 255... 1
Very stupid question, but I just can't figure out how to reverse this calculation. Can anyone point me in the right direction?
Solution
This should be done:
int value = max - progress;
It will gradually change from 255 (your maximum) to your minimum 1: (max – (max – min)) = > min = 1
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码