Remove Space between Drawable and Switch Button and Solve DrawableEnd Icon Problem

33 views Asked by At

How to solve this problem? theres a gap between icon and switch button.

Image 1 : Before

<androidx.appcompat.widget.SwitchCompat
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:drawableStart="@drawable/baseline_dark_mode_24"
   android:drawableEnd="@drawable/baseline_light_mode_24"/>

Theres Spaces between Drawable and Switch

Image 2 : After

I already changed the value of drawablePadding to negative one.. but drawableEnd still got stacked with Switch Button.

<androidx.appcompat.widget.SwitchCompat
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:minWidth="0dp"
   android:minHeight="0dp"
   android:drawablePadding="-12dp"
   android:drawableStart="@drawable/baseline_dark_mode_24"
   android:drawableEnd="@drawable/baseline_light_mode_24"/>

When i Add Drawable Padding -12 it solved, but how about with padding end drawable

Image 3 : with LinearLayout

There's still gap 'ight there

<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/baseline_dark_mode_24" />

        <androidx.appcompat.widget.SwitchCompat
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/baseline_light_mode_24" />

    </LinearLayout>

Image3

0

There are 0 answers