4

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

The values: 1 ... 255

The values i'd like to get: 255 ... 1

Pretty stupid question, but i just can't figure out how to reverse this calculation, could someone point me in the right direction?

  • Does a right-to-left setting work? http://stackoverflow.com/questions/7617187/android-seekbar-flipped-horizontally – apelsoczi May 05 '16 at 13:02

1 Answers1

10

This should do it :

int value = max - progress; 

It will go from 255 (your max) and gradually go to your minimum value which is 1 :(max - ( max - min )) => min = 1

Gauthier
  • 4,798
  • 5
  • 34
  • 44