如何设置Android动态壁纸图标(又名"缩略图")

phi*_*urn 15 android live-wallpaper

我构建了我的第一个Android应用.

这是一款专为2.2设计的动态壁纸.

当我按住屏幕,选择Wallpapers然后选择时Live Wallpapers,我的动态壁纸看起来像一个默认图标,其中我的动态壁纸的名称被覆盖.

如何设置此图标?

我的清单文件有一个指定为的应用程序图标 @drawable/icon

更新

我想我需要在这个问题上添加一些信息,因为它很难描述我的问题(对不起).

  1. 我有所有的res/drawable-[hml]dpi/图标.我把它们全部命名了icon.png.
  2. 我的清单文件包含 <application android:label="@string/app_name" android:icon="@drawable/icon">
  3. 我也试过在res/drawable/被叫中创建一个48x48图标icon.png.
  4. 如果允许,我还尝试在其他清单标记中明确添加图标.例如.服务,活动,intent-filter(很明显,我不知道这个清单文件是如何工作的,所以我在尝试任何事情)
  5. Manage Applications,图标显示正确.
  6. 选择动态壁纸时,图标无法正确显示.
  7. mdpi图标为48x48,ldpi图标为36x36,hdpi图标为72x72

小智 36

要在动态壁纸菜单中查看图标,您需要设置android:thumbnail应用程序<Wallpaper>标记的属性.这通常可以在与扩展的类对应的XML文件中找到WallpaperService.

查看CubeLiveWallpaper随SDK提供的示例应用程序,我们看到此标记位于cube1.xml和cube2.xml中.下面的修改版本显示了位于其中的图标thumb.png,res/drawable并提供了strings.xml中定义的描述

<wallpaper 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:thumbnail="@drawable/thumb"
    android:description="@string/description"
    android:settingsActivity="com.example.android.livecubes.cube2.CubeWallpaper2Settings"
/>
Run Code Online (Sandbox Code Playgroud)

注意:无论文件扩展名如何,这都适用,假设格式是受支持的类型 - jpg.png等

  • 只有这个答案是正确的; 所有其他人都错了.:-) (2认同)