Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display some value on seekbar as default?

I have a seekbar for example: from 0 to 10. How can I make if I want to set seekbar to 5 as default position. So in this example seekbar should start from middle.

like image 947
Adam Avatar asked Jan 10 '12 17:01

Adam


People also ask

How do I set the value of SeekBar?

One possible solution would be to set seekBar. setMax(20) (or android:max="20" in XML), and whenever you use or display the value, multiply it by 10. The SeekBar would then appear to move at least 20 at a time.

How do I manage SeekBar on android?

A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys. Placing focusable widgets to the left or right of a SeekBar is discouraged.

How do I change my thumb SeekBar?

Android supports it via xml. Just add android:thumbTint="@color/yourColor" in your seekbar.

How can I make my own SeekBar?

Now go to the activity_main. xml create a layout and inside the layout add a SeekBar. Specify the height width of SeekBar and the max progress that you want to use set progress to 0. This will create a customized Seekbar inside activity_main.


2 Answers

Use this one

android:progress="5" 

Like "progress", it inherits some of it's attributes from ProgressBar. You find all the attributes at http://developer.android.com/reference/android/widget/SeekBar.html

like image 89
mseo Avatar answered Oct 13 '22 10:10

mseo


To get Seekbar at the value of 5

In the xml layout use the max value as 10

  android:max="10"

In the java for seekbar to get at progress 5

 seekbar = (SeekBar) findViewById(R.id.seekBar1);
 seekbar.setProgress(5);

thats it :)

like image 41
Danny Avatar answered Oct 13 '22 10:10

Danny