Android material button icon aligned to the button

  android, button, material-design

Is there a way to align the icon to the start, top, and left of the material button in android XML? Do it programmatically is also acceptable.

I would expect app:iconPadding="0dp" to do that, but it doesn’t. The goal is something like this:

button with icon

My XML:

            <com.google.android.material.button.MaterialButton
                android:id="@+id/return_button"
                app:cornerRadius="40dp"
                app:icon="@drawable/icon_back"
                app:iconPadding="0dp"
                app:iconGravity="start"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                tools:text="RETURN" />

Source: Android Questions

LEAVE A COMMENT