Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot remove padding from Android Material slider

I've created a slider and I want to remove the padding. It seem it's not possible. I know there is some padding necessary for the thump, but I'd like to take care of the padding myself.

        <com.google.android.material.slider.Slider
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="0dp" />

Even with setting padding to 0 it still shows some padding. It seems the padding parameter is ignored. It also seems the thumb diameter is not taken into account for the padding.

image taken from layout inspector

How can I set the padding? What if I want a real big thumb diameter?

like image 926
kornale Avatar asked Oct 19 '25 03:10

kornale


1 Answers

If you add <dimen name="mtrl_slider_track_side_padding">0dp</dimen> in your dimens.xml, the paddings is gone, Is not the ideal solution but maybe works for you.

like image 172
AndroidRuntimeException Avatar answered Oct 22 '25 06:10

AndroidRuntimeException



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!