SeekBar set line thickness and color from code

S P picture S P · May 5, 2014 · Viewed 14.7k times · Source

I want to create a seek bar totally programmatically. All formatting is to be done from code itself. I cant even use a drawable from xml files.

Everything is working fine except the drawable for seek bar line. I can change the color of the line / change it to some drawable etc. but can't change the thickness of the line.

I am getting the following output:

output

But I want to achieve somewhat like the below thin line:

desired

Answer

Droid_Mechanic picture Droid_Mechanic · Dec 28, 2015

You can change the size/thickness of your seek-bar by just using two attributes of seekbar. Which are:

android:minHeight="2dip"

android:maxHeight="2dip"

For example:

            <SeekBar
                android:progressDrawable="@drawable/seek_progress"
                android:thumb="@drawable/thumb"
                android:id="@+id/seekDistance"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:max="80"
                android:minHeight="2dip"
                android:maxHeight="2dip"
                />