我可以为 Android 快捷方式功能中的图标着色吗?
Can I tint icon in Android shortcut feature?
我有一个像这样的 xml Android shortcut 特征:
<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>
既没有 android:tint="color"
也没有 android:iconTint="color"
。
您可以使用 Android Studio 的 Image Asset 创建快捷方式图标(用于静态快捷方式)
或使用动态快捷方式并通过 drawable.setTint(tint)
以编程方式为它们着色。
快捷方式图标不能包含色调。
我有一个像这样的 xml Android shortcut 特征:
<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>
既没有 android:tint="color"
也没有 android:iconTint="color"
。
您可以使用 Android Studio 的 Image Asset 创建快捷方式图标(用于静态快捷方式)
或使用动态快捷方式并通过 drawable.setTint(tint)
以编程方式为它们着色。
快捷方式图标不能包含色调。