Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a seekbar whose initail progress which is zero, starts in the middle

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

I'm a beginner in programming and I looked for tutorials, but every where the progress starts in the leftmost corner. Can someone please guide me how can I customize the SeekBar.

So In onProgresschanged.

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

Thanks.

like image 301
user2688158 Avatar asked Feb 26 '14 07:02

user2688158


People also ask

How do I change my SeekBar value?

In Order to the seekBar to Change while you are in the Activity you need to Call the method setProgress(), and pass it a boolean animate value.

What is difference between ProgressBar and SeekBar?

What is difference between ProgressBar and SeekBar? An example of SeekBar is your device's brightness control and volume control. Important Note: Attribute of a SeekBar are same as ProgressBar and the only difference is user determine the progress by moving a slider (thumb) in SeekBar.

What is discrete SeekBar?

In Android Discrete SeekBar is just an advancement of progressBar just like the SeekBar, the only difference in SeekBar and discrete SeekBar being that in discrete SeekBar, we can only set the value only to discrete values like 1, 2, 3, and so on.


1 Answers

Seekbars in Android cannot have negative values. Assuming you have specified a value of '100' for your maximum range of the progress bar (for example using setMax(100) or in your xml file using android:max="100"), then you can use this method to move your progress bar to the middle whenever you want (for example in your Activity.onCreate() or wherever else)

    yourProgressBar.setProgress(50);

After that you can get the progress value using:

    int progress = yourProgressBar.getProgress();

If you want to have a progress value between (e.g.) -50 to +50, then you can simply use:

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

Good luck.

like image 100
Joseph_Marzbani Avatar answered Sep 27 '22 22:09

Joseph_Marzbani