Search code examples
androidxmlandroid-layoutandroid-studioseekbar

Why are there spaces on the left and right hand side of my seekbar?


I am working on Seekbar and i have found one issue. A default space is present on the left and right hand side. I need the seekbar to be full width. I did match_parent and fill_parent but that didn't work.

enter image description here

<?xml version="1.0" encoding="utf-8"?>

 <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

   <SeekBar
      android:id="@+id/seek_bar_controller"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="0dp" />
 </RelativeLayout>

You can follow this snapshot for the reference, on both left and right hand sides space is present.

Please kindly go through my post and suggest some solution.


Solution

  • To remove that you need to use android:thumbOffset="20dp",

    try below code :

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <SeekBar
            android:id="@+id/seek_bar_controller"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:thumbOffset="20dp" />
    </RelativeLayout>