You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Android Wear表盘快捷方式指定自定义图标?

为Wear OS应用设置专属表盘快捷方式图标

实现思路

你看到Strava这类应用的表盘快捷方式用了专属图标,是因为它们没有直接使用应用主图标,而是通过自定义应用快捷方式指定了适配Complication显示的专用图标。下面是具体实现步骤:

步骤1:准备适配的图标资源

制作适合表盘Complication显示的图标(建议圆形,无多余边距,尺寸参考48x48dp前景层),将图标文件(比如ic_shortcut_fx_round.png)放到res/drawable目录下。

步骤2:添加静态快捷方式(推荐)

静态快捷方式随应用安装生效,无需运行时操作:

  1. 在AndroidManifest.xml的主Activity标签内添加元数据,引用快捷方式配置文件:
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <meta-data
        android:name="android.app.shortcuts"
        android:resource="@xml/shortcuts" />
</activity>
  1. 在res/xml目录下创建shortcuts.xml,定义专属快捷方式:
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:shortcutId="fx_launch"
        android:enabled="true"
        android:icon="@drawable/ic_shortcut_fx_round"
        android:shortcutShortLabel="@string/shortcut_fx"
        android:shortcutLongLabel="@string/shortcut_fx_full">
        <intent
            android:action="android.intent.action.VIEW"
            android:targetPackage="com.your.package.name"
            android:targetClass="com.your.package.name.MainActivity" />
    </shortcut>
</shortcuts>
  1. 在res/values/strings.xml中添加快捷方式的标签文字:
<string name="shortcut_fx">FX</string>
<string name="shortcut_fx_full">FX应用</string>

步骤3:动态创建快捷方式(可选)

如果需要在应用运行时创建/更新快捷方式,使用ShortcutManager:

val shortcutManager = getSystemService(ShortcutManager::class.java)
val fxShortcut = ShortcutInfo.Builder(this, "fx_launch")
    .setShortLabel(getString(R.string.shortcut_fx))
    .setLongLabel(getString(R.string.shortcut_fx_full))
    .setIcon(Icon.createWithResource(this, R.drawable.ic_shortcut_fx_round))
    .setIntent(Intent(Intent.ACTION_VIEW, null, this, MainActivity::class.java))
    .build()

shortcutManager.addDynamicShortcuts(listOf(fxShortcut))

验证效果

重新安装应用后,进入表盘自定义界面:选择「Complication」→「App shortcut」,找到你创建的「FX」快捷方式,添加后就能看到专属的圆形图标,而非缩小的方形主图标。

注意事项

  • 图标要适配Complication的小尺寸显示:尽量用纯色、简洁的圆形设计,避免复杂细节或多余边距。
  • 静态快捷方式优先级高于动态快捷方式,若同时存在,系统会优先显示静态的。
  • 确保shortcutId全局唯一,不要和其他快捷方式重复。

内容的提问来源于stack exchange,提问作者Klankster

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 21:17:48