【问题标题】:Cannot change AppWidget icon from the default无法更改默认的 AppWidget 图标
【发布时间】:2015-01-11 16:25:43
【问题描述】:

我的应用中有一个 AppWidget,但我无法让它在小部件抽屉中更改其图标。

我在 AndroidManifest 中设置了图标

<receiver android:name=".MealWidget"
        android:label="AwesomeWidget"
        android:icon="@drawable/ic_meals_icon">

并在appwidget-provider中设置PreviewImage:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
        android:previewImage="@drawable/ic_meals_icon" />

但图标仍然是默认的蓝色矩形,上面写着“EXAMPLE”。我错过了什么?

【问题讨论】:

  • 您是否完全卸载并重新安装了该应用程序?主屏幕可能正在缓存图像。
  • 卸载,重启手机,重新安装。还是一样。
  • 我手机上还是原图,别人手机上是新图。不太确定如何清除缓存的图标。
  • 我有同样的问题,你可以找到我的答案here

标签: android icons android-appwidget appwidgetprovider


【解决方案1】:

根据文档,这是在清单中声明小部件接收者的方式。

<receiver android:name="ExampleAppWidgetProvider" >
    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <meta-data android:name="android.appwidget.provider"
               android:resource="@xml/example_appwidget_info" />
</receiver>

欲了解更多信息,请参阅此链接

http://developer.android.com/guide/topics/appwidgets/index.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-30
    • 2014-11-05
    • 2012-05-07
    • 2018-05-23
    • 1970-01-01
    相关资源
    最近更新 更多