'How can I change icons color in button?

I created button with text and icon:

<Button
        android:id="@+id/btnLinkToProfile"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:text="@string/profile"
        android:gravity="left|center_vertical"
        android:textAllCaps="false"
        android:textColor="@color/text"
        android:textSize="15dp"
        android:drawableLeft="@drawable/profile"/>

And I want to set icon color, how to do this in <Button/> tag or it can be set only in <ImageView/> tag?



Solution 1:[1]

You can use the android:drawableTint="#000000" for the drawable like

<Button
    android:id="@+id/btnLinkToProfile"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:text="@string/profile"
    android:gravity="left|center_vertical"
    android:textAllCaps="false"
    android:textColor="@color/text"
    android:textSize="15dp" 
    android:drawableLeft="@drawable/profile"
    android:drawableTint="#000000"
    android:drawableTintMode="src_in"/>

Thank you

Solution 2:[2]

You can use an ImageButton and set the colour with

android:tint="@color/myColour"

Solution 3:[3]

app:iconTint="yourColor" works for MaterialButton

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jaykishan Gauswami
Solution 2 ManxDev
Solution 3 Samseen