How to create a breaker whose initial progress, which is zero, begins in the middle

I want to configure a SeekBar as shown in the image below. Make a seekbar like this one

I'm starting to program, and I was looking for tutorials, but everyone where progress begins in the far left. Can someone please call me how can I configure SeekBar.

So In onProgresschanged.

 @Override
 public void onProgressChanged(SeekBar seekBar,int progress, boolean fromUser) {            
brightness = progress;
    putGestureImageOnScreen(doBrightness(imageBitmap, brightness));
 }

Thanks.

+4
source share
5 answers

Android . , "100" (, setMax (100) xml android: max = "100" ), , (, Activity.onCreate() - )

    yourProgressBar.setProgress(50);

, :

    int progress = yourProgressBar.getProgress();

(, -50 +50), :

    int progress = yourProgressBar.getProgress();
    progress -= 50;

.

+11

AFAIK SeekBar Android. SeekBar 0 100. ..

seekbar.setMax(100);

, ..

seekbar.setProgress(50);

50 0

+3

xml : android:progress="20" , 20 . .

:

your_seekBar.setProgress(start_position);

. your_seekBar.setProgress(20)

,

0

Oncreate

 seekBar=((SeekBar)(v.findViewById(R.id.seekBar1)));
    seekBar.setMax(100);
    seekBar.setProgress(50); 
0

. this. , Max progress seekBar.

seekbar.setMax(100);
seekbar.setProgress(50);//Set default progress of the Seekbar
0

Source: https://habr.com/ru/post/1528906/


All Articles