Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button drawable icon not showing

I am trying to display a normal icon on before the text on the button. I know how it should work and I don't know why it doesn't.

Things I have already tried:

  • most basic and isolated button
  • multiple or no styles
  • multiple icons
  • all stack overflow answers I could find didn't work for me

Here is the code I use:

<Button
    style="@style/Widget.MaterialComponents.Button.OutlinedButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:drawableStart="@drawable/ic_check_black_24dp"
    android:text="Button with Left Icon" />

Any tips on what I could try or how I could make a button with icon differently?

like image 687
JojoIV Avatar asked Dec 11 '22 02:12

JojoIV


1 Answers

Try like this

<com.google.android.material.button.MaterialButton
    android:id="@+id/btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TEXT"
    style="@style/Widget.AppCompat.Button.Borderless"
    app:icon="@drawable/ic_refresh_black_24dp"

    />
like image 50
AhmetAcikalin Avatar answered Dec 31 '22 14:12

AhmetAcikalin