Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove tint on icon in Material Button?

I want to have "Sign in with Google" button with white background and colored icon, but when I use this Google icon always gets tinted.

  <android.support.design.button.MaterialButton
    style="@style/Widget.MaterialComponents.Button.Icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Sign in with Google"
    app:icon="@drawable/ic_google_colored"/>

How do I make icon not tinted?

like image 540
svkaka Avatar asked Oct 18 '18 17:10

svkaka


3 Answers

I already found a solution, I just changed iconTintMode and iconTint color

  <android.support.design.button.MaterialButton
    style="@style/Widget.MaterialComponents.Button.Icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Sign in with Google"
    app:icon="@drawable/ic_google_colored"
    app:iconTint="@android:color/transparent"
    app:iconTintMode="add"/>

I am open to better solutions

like image 103
svkaka Avatar answered Oct 29 '22 22:10

svkaka


Use this and quit tint icon to show real color

  app:icon="@drawable/ic_google"
  app:iconTint="@null"

Example

<Button
  android:id="@+id/idGoogle"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:icon="@drawable/ic_google"
  app:iconTint="@null"/>

icon with real color shows black background

like image 38
Rulogarcillan Avatar answered Oct 29 '22 22:10

Rulogarcillan


You can also use white color as iconTint and use multiply as iconTintMode for colorful icons.

 app:iconTint="@color/white"
 app:iconTintMode="multiply"
like image 1
Chintan Parmar Avatar answered Oct 29 '22 21:10

Chintan Parmar