How to customize the look of a SeekBar in Android?

Janusz picture Janusz · Jul 6, 2010 · Viewed 37.4k times · Source

I use a SeekBar in my application and I would like to customize it a little bit. I already figured out how to change the Drawable for the thumb and for the background.

My question is how to change the size of the SeekBar? If I just change the height of the SeekBar like this, theViewis only clipped and it only shows the top piece of theSeekBar`:

<SeekBar
   android:layout_height="10dip"
   style="@style/seekbar_style" />

How do I change the overall size of the Seekbar? I want it to be much thinner then the standard SeekBar.

Answer

Sephy picture Sephy · Jul 6, 2010

You have the equivalent of this of the Progress Bar for the seekbar indeed :

  <style name="Widget.SeekBar">
    <item name="android:indeterminateOnly">false</item>
    <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
    <item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
    <item name="android:minHeight">20dip</item>
    <item name="android:maxHeight">20dip</item>
    <item name="android:thumb">@android:drawable/seek_thumb</item>
    <item name="android:thumbOffset">8px</item>
    <item name="android:focusable">true</item>
  </style>

So you might want to override all this and do it your way, as you would do it for the title bar, by defining your own style.