listpreference

时间:2025-09-27 04:56:06编辑:小松

如何实现 Android 动态壁纸效果



Intent intent = new Intent(

WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);

intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,

new ComponentName(this, MyWallpaperService.class));

startActivity(intent);

}

动态壁纸应用实际上和其他应用是很相似的。下面我们一步一步来学习怎么创建一款动态壁纸应用。最终的实现效果如下:

代码示例
创建一个新的Project,可以选择不要Activity。但是为了让用户直接跳转到壁纸设置页面,我们创建了一个MainActivity。让用户能够对我们提供的壁纸进行设置,我们再创建一个SettingActivity。
在/res/xml文件夹下创建normal_wallpaper.xml,当然名字可以自取。包含如下内容。注意android:settingsActivity的值,是刚才创建的SettingActivity的包名,可能你需要修改。


<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"

android:description="@string/normal_wallpaper_des"

android:settingsActivity="com.yalin.wallpaper.demo.SettingActivity"

android:thumbnail="@drawable/ic_launcher_round" />

这个文件包含了壁纸的描述和图标,同时包含一个设置页面(设置页面是可选的)。
这个文件会在AndroidManifest.xml中用到。
创建一个NormalWallpaperService类,暂时不用实现里面的方法。
public class NormalWallpaperService extends WallpaperService {

@Override

public Engine onCreateEngine() {

return null;

}

}

同时在AndroidManifest.xml中声明它。meta-data中的resource指定上面创建的XML文件。
<service

android:name=".normal.NormalWallpaperService"

android:enabled="true"

android:label="@string/wallpaper"

android:permission="android.permission.BIND_WALLPAPER">







<meta-data

android:name="android.service.wallpaper"

android:resource="@xml/normal_wallpaper" />



我们还必须在AndroidManifest.xml中增加下面的代码:
<uses-feature

android:name="android.software.live_wallpaper"

android:required="true" >



到此我们的基本配置已经OK了。


如何在MultiSelectList preference设置多个默认值

To make all MultiSelectListPreference items selected (on) by default, then include the attribute defaultsValue for the Preference, e.g.
android:defaultValue="@array/stores"
If it's not working, then make sure that you clear the appliction data as this will only take effect the first time the application is run.


nexus live wallpaper装在IPHONE上的,要怎么设置才能把锁屏也变成动态背景的

1、先从Cydia中下载vWallpaper,如图是下载时的截图: 2、打开vWallpaper,选择第一个“Video Wallpaper” 3、选择第二个"Video Select"进入,注意:"Enable Video!"一定要是打开状态。以后可以随时进来这里关闭动态桌面。 4、选择你想要的动态桌面,然后再点击“Yes,i Want”。有些XD(小弟)关心耗内存的问题我把动态桌面打开的情况下,我去BossPref里面查看,发现iPod并未打开。我不明白vWallpaper是什么工作原理,但是iPod没打开是件好事,就是说没有常驻内存或者说没有消耗iPod那类的进程。可以看下面截图。

上一篇:财务共享

下一篇:没有了