• 周六. 4 月 25th, 2026

物嫩软件资讯网

软件资讯来物嫩

LibGDX制作android动态壁纸

admin@wunen

5 月 17, 2025


一、还是像普通的android动态壁纸一样,创建一个没有activity的安卓工程TestLibGDXWallpaper



二、


AndroidManifest.xml配置

  1. <application
  2. android:icon=”@drawable/icon”
  3. android:label=”@string/app_name” >
  4. <service
  5. android:name=”.MyLiveWallpaper”
  6. android:icon=”@drawable/icon”
  7. android:label=”@string/app_name”
  8. android:permission=”android.permission.BIND_WALLPAPER” >
  9. <intent-filter>
  10. <action android:name=”android.service.wallpaper.WallpaperService” />
  11. </intent-filter>
  12. <meta-data
  13. android:name=”android.service.wallpaper”
  14. android:resource=”@xml/livewallpaper” />
  15. </service>
  16. </application>


复制代码


1、权限


android:permission=”android.permission.BIND_WALLPAPER”,否则该壁纸只能预览,不能被实际应用



2、


添加声明


android:name=”android.service.wallpaper.WallpaperService”以便系统识别



3、

android:name=”.MyLiveWallpaper”为动态壁纸的service类

4、meta-data部分为动态壁纸的配置信息xml/livewallpaper需要手动创建res/xml/livewallpaper.xml



三 、


livewallpaper.xml

  1. <?xml version=”1.0″ encoding=”utf-8″?>
  2. <wallpaper xmlns:android=”http://schemas.android.com/apk/res/android”
  3. android:thumbnail=”@drawable/icon” />


复制代码

只是配置其图标(没有“设置”项)

四、jar包和.so库导入

将从官方下载下来的压缩包中的gdx.jar和gdx-backend-android.jar包复制到工程libs目录下(再build path 步骤省略),将相关.so库复制到libs目录下!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注