Search code examples
androidshortcut

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>

Solution

  • 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).