动态壁纸 Live Wallpaper 应用程序必须实现动态壁纸的服务程序 WallpaperService 和描绘动态壁纸的引擎 WallpaperService.Engine
2015-05-07 14:00
609 查看
动态壁纸Live Wallpaper架构
动态壁纸 Live Wallpaper 应用程序必须实现动态壁纸的服务程序
WallpaperService 和描绘动态壁纸的引擎
WallpaperService.Engine ,当你需要设置动态壁纸的参数来改变动画的属性时,必须提供设置参数的窗体。此时才需要实现动态壁纸的参数设置窗体
PreferenceActivity 。
咱们先来说一次简单的步骤:
(1) 建一个类继承
WallpaperService ,比如说为 Live Wallpaper.java
(2) 然后在AndrodManifest.XML文件的<service>标签内定义动态壁纸的服务程序
Live Wallpaper.java和动态壁纸的资源来源“/res/XML/
live Wallpaper.XML”
(3) 还需要增加一个<Activity>标签来设置动态壁纸参数设置程序HelloLive
WallpaperSetting.java ,当然这个要去继承
PreferenceActivity
AndrodManifest.XML
/res/XML/ live Wallpaper.XML
参数设置界面的布局代码 settings.xml
这是一个我自己编写的简单动态壁纸效果图:
动态壁纸Live Wallpaper架构
组件类 | 说明 |
WallpaperService | 实现动态壁纸的服务程序 |
WallpaperService.Engine | 描绘动态壁纸的引擎 |
PreferenceActivity | 动态壁纸的参数设置窗体 |
WallpaperService 和描绘动态壁纸的引擎
WallpaperService.Engine ,当你需要设置动态壁纸的参数来改变动画的属性时,必须提供设置参数的窗体。此时才需要实现动态壁纸的参数设置窗体
PreferenceActivity 。
咱们先来说一次简单的步骤:
(1) 建一个类继承
WallpaperService ,比如说为 Live Wallpaper.java
(2) 然后在AndrodManifest.XML文件的<service>标签内定义动态壁纸的服务程序
Live Wallpaper.java和动态壁纸的资源来源“/res/XML/
live Wallpaper.XML”
(3) 还需要增加一个<Activity>标签来设置动态壁纸参数设置程序HelloLive
WallpaperSetting.java ,当然这个要去继承
PreferenceActivity
AndrodManifest.XML
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.njue.livewallpaper" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" /> <application android:icon="@drawable/icon" android:label="@string/app_name" > <service android:label="@string/app_name" android:permission="android.permission.BIND_WALLPAPER" android:name=".LiveWallpaper"> <intent-filter> <action android:name="android.service.wallpaper.WallpaperService" /> </intent-filter> <meta-data android:name="android.service.wallpaper" android:resource="@xml/livewallpaper" /> </service> <activity android:name=".LiveWallpaperSettings" android:label="@string/wallpaper_settings" android:theme="@android:style/Theme.Light.WallpaperSettings" android:exported="true"> </activity> </application> </manifest>
/res/XML/ live Wallpaper.XML
<?xml version="1.0" encoding="UTF-8"?> <wallpaper xmlns:android="http://schemas.android.com/apk/res/android" android:thumbnail="@drawable/floewr1" android:description="@string/description" android:settingsActivity="com.njue.livewallpaper.LiveWallpaperSettings" />
参数设置界面的布局代码 settings.xml
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/settings"> <ListPreference android:key="@string/leaf1Count" android:title="@string/settings_title" android:summary="@string/settings_summary" android:entries="@array/entries" android:entryValues="@array/values" /> <ListPreference android:key="@string/flower1Count" android:title="@string/settings_title1" android:summary="@string/settings_summary1" android:entries="@array/entries" android:entryValues="@array/values" /> <ListPreference android:key="@string/flower2Count" android:title="@string/settings_title2" android:summary="@string/settings_summary2" android:entries="@array/entries" android:entryValues="@array/values" /> <EditTextPreference android:key="@string/inputText" android:title="输入你喜欢的文字" android:summary="点击输入" android:dialogTitle="输入文字设置" /> <EditTextPreference android:key="@string/wordCount" android:title="一列显示的字符数" android:summary="请输入数字" android:dialogTitle="一列显示的字符数(请输入数字)" android:digits="0123456789" /> <PreferenceCategory android:title="恢复默认设置" > <CheckBoxPreference android:key="@string/reset" android:title="恢复默认设置" android:summaryOn="恢复默认设置" android:summaryOff="恢复默认设置" android:defaultValue="false" ></CheckBoxPreference> </PreferenceCategory> </PreferenceScreen>
这是一个我自己编写的简单动态壁纸效果图:
相关文章推荐
- 在ASP.NET AJAX中使用应用程序服务和本地化(2):示例程序:实现用户登录和注销
- Android动态壁纸 Live Wallpaper(WallpaperService.Engine)
- 出现“无法通过windows installer服务安装此安装程序包。您必须安装带有更新版本Windows Installer服务的Windows Service Pack”提示如何解决?
- python实现windows Service服务程序
- SilverLight企业应用框架设计【四】实体层设计+为客户端动态生成服务代理(自己实现RiaService)
- 添加服务,用于定期执行某个程序或者应用程序(windows service)
- Windows Service服务程序的原理及实现(0)服务主函数 & 控制处理函数
- 在Android中实现Service动态更新UI界面(Service与主程序Activity之间的数据交互或控制)
- CloudStack服务引擎配置(cloud-engine-service模块)
- C#程序实现动态调用DLL的研究
- C# 编写Windows Service(windows服务程序)【转载】
- .Net Remoting(分离服务程序实现) - Part.3
- Android 通过JNI实现守护进程,使得Service服务不被杀死
- Android窗口管理服务WindowManagerService对壁纸窗口(Wallpaper Window)的管理分析
- 【远程调用框架】如何实现一个简单的RPC框架(三)优化一:利用动态代理改变用户服务调用方式
- Thrift和Zookeeper实现的动态服务调用的功能
- VC程序中实现控件的动态生成与响应
- 使用事件驱动模型实现网络服务程序
- 在ASP.NET AJAX中使用应用程序服务和本地化(5):自定义应用程序服务的服务器端实现
- android设置动态壁纸 (Wallpaper) 介绍