Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make SeekBar take up full width of parent

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.

like image 380
David Heisnam Avatar asked Sep 02 '14 06:09

David Heisnam


People also ask

How can I increase my SeekBar size?

Edit the maxHeight to your desired height what you want to achieve. It will work perfectly. Show activity on this post. You have to add some padding for all directions and also set the min and max height of the SeekBar.

How do I change the width of SeekBar?

You can use the Slider provided by the Material Components Library. Use the app:trackHeight="xxdp" (the default value is 4dp ) to change the height of the track bar.

How do I change the SeekBar thumb size on android?

Show activity on this post. Then I used vector code in . xml file, which has attrs android:width="28dp" and android:height="28dp" in the vector tag. Here we can change the size of the thumb.

How do I change the progress of a SeekBar?

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.


1 Answers

Try to define following with the SeekBar in xml:

android:padding="0dp"
like image 161
Niko Avatar answered Oct 13 '22 00:10

Niko