Android动态壁纸 Live Wallpaper(WallpaperService.Engine)
组件类 |
说明 |
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
- <?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/liveWallpaper.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>
这是一个我自己编写的简单动态壁纸效果图:
Android动态壁纸 Live Wallpaper(WallpaperService.Engine)相关推荐
- Android动态壁纸 Live Wallpaper
动态壁纸Live Wallpaper架构 组件类 说明 WallpaperService 实现动态壁纸的服务程序 WallpaperService.Engine 描绘动态壁纸的引擎 Preferenc ...
- android 动态壁纸开发
转:http://www.eoeandroid.com/thread-100389-1-1.html android 动态壁纸开发 参考:http://www.ophonesdn.com/articl ...
- android动态壁纸的制作
对于Android 2.1来说Live Wallpapers动态壁纸的加入为Android桌面加入了更好的动态效果.如何开发一个Android动态桌面呢? 下面Android123给大家一个详细的步骤 ...
- Android动态壁纸解析
转载自 Yalin Jin的文章:http://www.kinglloy.com/ MENU Android动态壁纸解析 24 JULY 2017 阅读之前 建议下载使用Style动态壁纸应用 文章后 ...
- Android 动态壁纸开发(时钟)
Android 动态壁纸开发(时钟) 这是我人生第一篇文章,希望大家不喜无喷啊!有兴趣的可以看看玩,因为语言组织能力有限,就废话不多说直接进入重点! 先看效果 上图是动态壁纸钟的一个时钟. 我们先来看 ...
- Android动态壁纸详解
动态壁纸 Livewallpaper(动态壁纸): 首先动态壁纸并不是GIF图片,而是一个独立的应用程序,本质是一个Service,甚至可以没有桌面图标. 直接看AndroidManifest.xml ...
- Android 动态壁纸引擎试刀学习(初识安卓引擎)
动态壁纸蛮好玩的,也没接触过,看官方有就拿了学习下,是小马第一次接触引擎Engine,激动兴奋...效果做出来了,就放博客里,记录笔记,吼吼,跟大家交流学习, 废话不多说了,先看效果,再看源码,之后小 ...
- LibGDX制作android动态壁纸
一.还是像普通的android动态壁纸一样,创建一个没有activity的安卓工程TestLibGDXWallpaper 二.AndroidManifest.xml配置 <application ...
- 制作android动态壁纸,如何使用LibGDx制作Android动态壁纸?
我想制作 Android动态壁纸.我想使用LibGDx.我发现了这个信息: http://www.badlogicgames.com/wordpress/?p=2652 不幸的是,我的壁纸复制代码,e ...
最新文章
- SAP PM创建/计划MO
- 从补码的来源剖析到为啥补码=原码按位取反+1
- .Net Core和Jexus配置HTTPS服务
- 【CodeForces - 670D1 】Magic Powder - 1 (模拟 或 枚举 或二分优化)
- php获取表单内的值,PHP获取表单里各项值总结
- Android Studio下载
- java 及时编译_Java 面试-即时编译( JIT )
- CISCO 路由器的E1模块配置指南
- Tensorflow2.0数据和部署(一)——基于浏览器的模型与TensorFlow.js
- 莫队(bzoj 2038: [2009国家集训队]小Z的袜子(hose))
- java 删除文件路径下的指定文件
- LaTeX中常用的模板,命令和技巧
- 苹果雪豹操作系统正式版_苹果为旧机型发布iOS 12.4.2;macOS 10.14.6发布了,Catalina还远吗?...
- EXCEL生成MySql建表语句
- J-LINK 软件下载地址
- HDU 5441并查集 by cyl
- 宝库\要出发 IOS面试试题
- 关闭centos7下哔哔声
- 第一个ASP.net的CRED(创建读取编辑删除)页面
- JWT的初步了解以及session、cookie机制