Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SeekBar mark where are the values

I have SeekBar with 3 value (left, on center and right) and I will like to put some mark where progess level are, e.g. on center to put vertical line over bar or something like that.

Is this possible or it's might be better to use some different component?

Like on this image, I need something like this red line

like image 466
Kec Avatar asked Nov 02 '11 08:11

Kec


People also ask

How do I customize 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.

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 the SeekBar thumb on Android?

Just add android:thumbTint="@color/yourColor" in your seekbar.

How do I SeekBar progress?

You are looking for the method getProgress() of the ProgressBar class as SeekBar is a subclass of ProgressBar . So basically it would be something like that. int value = seekBar. getProgress();


1 Answers

You can use the setBackgroundDrawable(Drawable d). Save an image of what you want the labels to be in a png image then add it to your resources in your project.

Here is some code I used, where my image was the android launcher icon:

seekbar = (SeekBar) findViewById(R.id.seekBar1);
Resources r = getResources();
Drawable d = r.getDrawable(R.drawable.ic_launcher);
seekbar.setBackgroundDrawable(d);
like image 56
Manar Bushnaq Avatar answered Oct 15 '22 18:10

Manar Bushnaq