How to make SeekBar take up full width of parent

DavidH picture DavidH · Sep 2, 2014 · Viewed 10.7k times · Source

I have a SeekBar in a RelativeLayout whose width is equal to the screen width.

I applied layout_width="match_parent" to the SeekBar but it seems to keep some empty space on both sides of the SeekBar to accommodate the thumb.

I also tried using android:thumb="@null" The thumb is gone but not the empty space on the sides.

I really need to make the SeekBar width match the parent's. Could somebody help me with this? Maybe I could create a custom SeekBar class and set the width to the parent width in onMeasure(). If this is a possible solution, I don't know how I could pass the parent width to the SeekBar class.

Any help is appreciated. Thank you.

Answer

Niko picture Niko · Sep 2, 2014

Try to define following with the SeekBar in xml:

android:padding="0dp"