2

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?

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
kewin123
  • 137
  • 1
  • 4
  • 16
  • See : [how to change color of compounddrawable on button](https://stackoverflow.com/questions/38926123/how-to-change-color-of-compounddrawable-on-button) – Kévin Giacomino Jan 23 '19 at 13:31
  • Possible duplicate of [Change android button drawable icon color programmatically](https://stackoverflow.com/questions/46714018/change-android-button-drawable-icon-color-programmatically) – Umair Jan 23 '19 at 13:33

3 Answers3

3

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

3

app:iconTint="yourColor" works for MaterialButton

Samseen
  • 87
  • 5
  • 13
1

You can use an ImageButton and set the colour with

android:tint="@color/myColour"
ManxDev
  • 98
  • 2
  • 12