Java – How do I reverse the SeekBar value?

How do I reverse the SeekBar value?… here is a solution to the problem.

How do I reverse the SeekBar value?

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

Value: 1 … 255

The value I want to get: 255 … 1

Very stupid question, but I just can’t figure out how to reverse this calculation, can someone point me in the right direction?

Solution

It should be done :

int value = max - progress; 

It will gradually change from 255 (your maximum) to your minimum value of 1 :(max – ( max – min )) = > min = 1

Related Problems and Solutions