kewin123
kewin123

Reputation: 147

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?

Upvotes: 3

Views: 4915

Answers (3)

Samseen
Samseen

Reputation: 97

app:iconTint="yourColor" works for MaterialButton

Upvotes: 4

Jaykishan Gauswami
Jaykishan Gauswami

Reputation: 94

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

Upvotes: 4

ManxDev
ManxDev

Reputation: 108

You can use an ImageButton and set the colour with

android:tint="@color/myColour"

Upvotes: 1

Related Questions