Android: How to fix Seekbar bar thumb centering issues.

If you ever need to change the height of your Seekbar you may find that the thumb is not centering properly.
The fix for this is actually pretty simple. It just took me a while to find, so i'm posting this in the hopes of helping fellow developers cut down on their search time.
After trying things like gravity and margins and such with no success, i wondered well how the heck does android do it anyway?
That led me to seeing how they define their default seekbar style.
- false
- @android:drawable/progress_horizontal
- @android:drawable/progress_horizontal
- 20dip
- 20dip
- @android:drawable/seek_thumb
- 8dip
- true
Which i then compared to mine.
- fill_parent
- 60dp
- @drawable/slider_thumb
- @drawable/seekbar
What immediately caught my eye was the minHeight and maxHeight attributes. It's possible that when this widget is being laid out android takes these values into account so I tried it.
- fill_parent
- 60dp
- 60dp
- 60dp
- @drawable/slider_thumb
- @drawable/seekbar
Lo and behold it worked!

So what's the answer?
If you need to adjust the height of your seekbar make sure you define the minHeight and maxHeight attributes or your Seekbar because android takes them into account when placing the thumb.

March 28th, 2012 - 02:38
Thanks for sharing. i was looking the exact thing. I also want to move the seekbar thumb to secondaryprogress instead of progress. Can I do so?? Much appreciated help needed
April 11th, 2012 - 09:47
Hi Rikki,
I’m not sure if I’m clear on what you’re asking for. It sounds like you just don’t want to progress to be there? just the secondary progress?
You can be tricky and just make them both the same color. or make the progress bar transparent.
Hope that helps, let me know if that’s not what you’re looking for.