源码下载:http://download.csdn.net/detail/heng615975867/6533429
动态壁纸Live Wallpaper架构

组件类

说明

WallpaperService

实现动态壁纸的服务程序

WallpaperService.Engine

描绘动态壁纸的引擎

PreferenceActivity

动态壁纸的参数设置窗体

动态壁纸Live Wallpaper应用程序必须实现动态壁纸的服务程序WallpaperService和描绘动态壁纸的引擎WallpaperService.Engine,当你需要设置动态壁纸的参数来改变动画的属性时,必须提供设置参数的窗体。此时才需要实现动态壁纸的参数设置窗体PreferenceActivity。

咱们先来说一次简单的步骤:

(1)建一个类继承WallpaperService,比如说为LiveWallpaper.java

(2)然后在AndrodManifest.XML文件的<service>标签内定义动态壁纸的服务程序LiveWallpaper.java和动态壁纸的资源来源“/res/XML/liveWallpaper.XML”

(3)还需要增加一个<Activity>标签来设置动态壁纸参数设置程序HelloLiveWallpaperSetting.java,当然这个要去继承PreferenceActivity

AndrodManifest.XML

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.njue.livewallpaper"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6. <uses-sdk android:minSdkVersion="7" />
  7. <application
  8. android:icon="@drawable/icon"
  9. android:label="@string/app_name" >
  10. <service
  11. android:label="@string/app_name"
  12. android:permission="android.permission.BIND_WALLPAPER"
  13. android:name=".LiveWallpaper">
  14. <intent-filter>
  15. <action android:name="android.service.wallpaper.WallpaperService" />
  16. </intent-filter>
  17. <meta-data android:name="android.service.wallpaper"
  18. android:resource="@xml/livewallpaper" />
  19. </service>
  20. <activity android:name=".LiveWallpaperSettings"
  21. android:label="@string/wallpaper_settings"
  22. android:theme="@android:style/Theme.Light.WallpaperSettings"
  23. android:exported="true">
  24. </activity>
  25. </application>
  26. </manifest>

/res/XML/liveWallpaper.XML

[html]  view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <wallpaper
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:thumbnail="@drawable/floewr1"
  5. android:description="@string/description"
  6. android:settingsActivity="com.njue.livewallpaper.LiveWallpaperSettings"
  7. />

参数设置界面的布局代码settings.xml

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <PreferenceScreen
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:title="@string/settings">
  5. <ListPreference
  6. android:key="@string/leaf1Count"
  7. android:title="@string/settings_title"
  8. android:summary="@string/settings_summary"
  9. android:entries="@array/entries"
  10. android:entryValues="@array/values" />
  11. <ListPreference
  12. android:key="@string/flower1Count"
  13. android:title="@string/settings_title1"
  14. android:summary="@string/settings_summary1"
  15. android:entries="@array/entries"
  16. android:entryValues="@array/values" />
  17. <ListPreference
  18. android:key="@string/flower2Count"
  19. android:title="@string/settings_title2"
  20. android:summary="@string/settings_summary2"
  21. android:entries="@array/entries"
  22. android:entryValues="@array/values" />
  23. <EditTextPreference
  24. android:key="@string/inputText"
  25. android:title="输入你喜欢的文字"
  26. android:summary="点击输入"
  27. android:dialogTitle="输入文字设置"
  28. />
  29. <EditTextPreference
  30. android:key="@string/wordCount"
  31. android:title="一列显示的字符数"
  32. android:summary="请输入数字"
  33. android:dialogTitle="一列显示的字符数(请输入数字)"
  34. android:digits="0123456789"
  35. />
  36. <PreferenceCategory
  37. android:title="恢复默认设置"
  38. >
  39. <CheckBoxPreference
  40. android:key="@string/reset"
  41. android:title="恢复默认设置"
  42. android:summaryOn="恢复默认设置"
  43. android:summaryOff="恢复默认设置"
  44. android:defaultValue="false"
  45. ></CheckBoxPreference>
  46. </PreferenceCategory>
  47. </PreferenceScreen>

这是一个我自己编写的简单动态壁纸效果图:

Android动态壁纸 Live Wallpaper(WallpaperService.Engine)相关推荐

  1. Android动态壁纸 Live Wallpaper

    动态壁纸Live Wallpaper架构 组件类 说明 WallpaperService 实现动态壁纸的服务程序 WallpaperService.Engine 描绘动态壁纸的引擎 Preferenc ...

  2. android 动态壁纸开发

    转:http://www.eoeandroid.com/thread-100389-1-1.html android 动态壁纸开发 参考:http://www.ophonesdn.com/articl ...

  3. android动态壁纸的制作

    对于Android 2.1来说Live Wallpapers动态壁纸的加入为Android桌面加入了更好的动态效果.如何开发一个Android动态桌面呢? 下面Android123给大家一个详细的步骤 ...

  4. Android动态壁纸解析

    转载自 Yalin Jin的文章:http://www.kinglloy.com/ MENU Android动态壁纸解析 24 JULY 2017 阅读之前 建议下载使用Style动态壁纸应用 文章后 ...

  5. Android 动态壁纸开发(时钟)

    Android 动态壁纸开发(时钟) 这是我人生第一篇文章,希望大家不喜无喷啊!有兴趣的可以看看玩,因为语言组织能力有限,就废话不多说直接进入重点! 先看效果 上图是动态壁纸钟的一个时钟. 我们先来看 ...

  6. Android动态壁纸详解

    动态壁纸 Livewallpaper(动态壁纸): 首先动态壁纸并不是GIF图片,而是一个独立的应用程序,本质是一个Service,甚至可以没有桌面图标. 直接看AndroidManifest.xml ...

  7. Android 动态壁纸引擎试刀学习(初识安卓引擎)

    动态壁纸蛮好玩的,也没接触过,看官方有就拿了学习下,是小马第一次接触引擎Engine,激动兴奋...效果做出来了,就放博客里,记录笔记,吼吼,跟大家交流学习, 废话不多说了,先看效果,再看源码,之后小 ...

  8. LibGDX制作android动态壁纸

    一.还是像普通的android动态壁纸一样,创建一个没有activity的安卓工程TestLibGDXWallpaper 二.AndroidManifest.xml配置 <application ...

  9. 制作android动态壁纸,如何使用LibGDx制作Android动态壁纸?

    我想制作 Android动态壁纸.我想使用LibGDx.我发现了这个信息: http://www.badlogicgames.com/wordpress/?p=2652 不幸的是,我的壁纸复制代码,e ...

最新文章

  1. SAP PM创建/计划MO
  2. 从补码的来源剖析到为啥补码=原码按位取反+1
  3. .Net Core和Jexus配置HTTPS服务
  4. 【CodeForces - 670D1 】Magic Powder - 1 (模拟 或 枚举 或二分优化)
  5. php获取表单内的值,PHP获取表单里各项值总结
  6. Android Studio下载
  7. java 及时编译_Java 面试-即时编译( JIT )
  8. CISCO 路由器的E1模块配置指南
  9. Tensorflow2.0数据和部署(一)——基于浏览器的模型与TensorFlow.js
  10. 莫队(bzoj 2038: [2009国家集训队]小Z的袜子(hose))
  11. java 删除文件路径下的指定文件
  12. LaTeX中常用的模板,命令和技巧
  13. 苹果雪豹操作系统正式版_苹果为旧机型发布iOS 12.4.2;macOS 10.14.6发布了,Catalina还远吗?...
  14. EXCEL生成MySql建表语句
  15. J-LINK 软件下载地址
  16. HDU 5441并查集 by cyl
  17. 宝库\要出发 IOS面试试题
  18. 关闭centos7下哔哔声
  19. 第一个ASP.net的CRED(创建读取编辑删除)页面
  20. JWT的初步了解以及session、cookie机制

热门文章

  1. Excel获取当前文件所在目录
  2. 火狐弹窗漏洞 11 年仍未修复;谷歌被指将合规网站标记为恶意
  3. GLASS数据预处理/MRT工具批量处理MODIS数据
  4. Axure RP 10 for Mac (交互原型设计神器) v10.0.0
  5. 将jsp变为html
  6. 让我们一起祈祷,祝愿祖国平平安安
  7. 社交、内容、硬件,谁会成为工具类app的救命稻草?
  8. web调用IC卡读卡器开发第一章
  9. Quantum LeaPs(QP)的资料
  10. 03论文阅读与分享————2020年中国知网六自由度机器人轨迹规划相关论文统计