我可以在Android快捷方式功能中设置图标吗?

时间:2017-02-02 08:12:30

标签: android shortcut

对于Android shortcut功能,我有一个像这样的xml:

<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>

目前我的图标是矢量绘图,它有白色调。

我可以在文件定义中以某种方式使用不同的色调吗?如下所示:

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

</shortcut>

2 个答案:

答案 0 :(得分:3)

既没有android:tint="color"也没有android:iconTint="color"

您可以使用 Android Studio 图片资源来创建快捷方式图标(用于静态快捷方式)

或使用动态快捷方式,并通过drawable.setTint(tint)以编程方式对其进行着色。

答案 1 :(得分:1)

快捷方式图标不能包含色调。

refrence