Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I tint icon in Android shortcut feature?

I have an xml like this for Android shortcut feature:

<shortcuts
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:shortcutId="some_id"
        android:enabled="true"
        android:icon="@drawable/ic_icon"
        android:shortcutShortLabel="@string/short_label"
        android:shortcutLongLabel="@string/long_label"
        tools:targetApi="n_mr1">
        <intent
            android:action="android.intent.action.MAIN"
            android:targetPackage="my.package"
            android:targetClass="my.package.MainActivity" />
    </shortcut>
</shortcuts>

Currently my icon is a vector drawable and it has a white tint.

Can I somehow use a different tint here in the file definition? So something like:

<shortcut
    ...
    android:icon="@drawable/ic_icon"
    android:iconTint="#0000ff"
    ...>

</shortcut>
like image 345
ktamas Avatar asked Feb 02 '17 08:02

ktamas


2 Answers

There neither is a android:tint="color" nor android:iconTint="color".

You could use Android Studio's Image Asset to create a shortcut icon (for static shortcuts)

or use dynamic shortcuts and tint them programmatically via drawable.setTint(tint).

like image 129
Tobias Avatar answered Sep 27 '22 22:09

Tobias


Shortcut icons cannot include tints.

refrence

like image 26
abbasalim Avatar answered Sep 27 '22 22:09

abbasalim