導航:首頁 > 操作系統 > android動態壁紙

android動態壁紙

發布時間:2022-01-26 12:07:15

『壹』 android 怎麼讓live wallpaper動態壁紙運行起來

對於Android 2.1來說Live Wallpapers動態壁紙的加入為Android桌面加入了更好的動態效果。如何開發一個Android動態桌面呢? 下面Android123給大家一個詳細的步驟創建屬於你自己的Live Wallpaper吧。

1. 首先我使用Eclipse創建一個標準的Android工程這里package name我們使用cn.com.android123.cwj,然後進入工程的/res/文件夾,刪除layout這個文件夾,當然裡面的main.xml也會被刪除的,對於Live Wallpaper來說傳統的布局文件是不需要的。

2. 類似AppWidget一樣,我們可以加入動態壁紙的設置界面,我們在/res/文件夾中新建一個名為xml的文件夾,新建一個utf8編碼的xml文件,名為livewallpaper.xml,內容為

<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="cn.com.android123.cwj.LiveWallpaperSettings"
android:thumbnail="@drawable/icon"/>
這里我們可以看到上面的節點名為wallpaper,而設置的界面為 cn.com.android123.cwj.LiveWallpaperSettings 這個Activity,而在添加動態壁紙時顯示圖標為/res/drawable/icon 這個文件,同時我們再創建一個xml文件用於LiveWallpaperSettings這個Activity的布局,我們起名為livewallpaper_settings.xml內容為
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/livewallpaper_settings"
android:key="livewallpaper_settings">

<ListPreference
android:key="livewallpaper_testpattern"
android:title="標題"
android:summary="簡單描述"
android:entries="@array/livewallpaper_testpattern_names"
android:entryValues="@array/livewallpaper_testpattern_prefix"/>

<CheckBoxPreference android:key="livewallpaper_movement"
android:summary="動態描述"
android:title="動態標題"
android:summaryOn="動態測試"
android:summaryOff="靜止測試"/>
</PreferenceScreen>
3. 創建一個名為LiveWallpaper的類作為動態壁紙的主類,從WallpaperService父類繼承,這里我們可以像寫標准Android服務那樣開發
4. 新建類LiveWallpaperSettings從 PreferenceActivity 繼承實現我們的設置界面,代碼如下
public class LiveWallpaperSettings extends PreferenceActivity implements
SharedPreferences. {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
getPreferenceManager().setSharedPreferencesName(
LiveWallpaper.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.livewallpaper_settings);
getPreferenceManager().getSharedPreferences()
.register(this);
}

@Override
protected void onResume() {
super.onResume();
}

@Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences()
.unregister(this);
super.onDestroy();
}

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
}
同時仍然在androidmanifest.xml中加入 下面的代碼。
<activity android:label="@string/livewallpaper_settings"
android:name=".LiveWallpaperSettings"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true"
android:icon="@drawable/icon">
</activity>
5. 由於Android動態壁紙是2.1 API Level為7才加入的,所以設置好minSDK以及需要設備支持動態壁紙,我們在androidmanifest.xml中加入
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
6. 對於文中ListPreference用到的數組,及代碼中涉及的顏色數組,我們在/res/values/ 文件夾中創建一個名為testpatterns.xml 的文件,內容為
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="livewallpaper_testpattern_names">
<item>"Color Bars 16x9"</item>
<item>"Color Bars 4x3"</item>
<item>"EBU Color Bars"</item>
</string-array>

<string-array name="livewallpaper_testpattern_prefix">
<item>"smpte"</item>
<item>"bars"</item>
<item>"ebu"</item>
</string-array>

<integer-array name="smptecolors">
<item>0xFF696969</item>
<item>0xFFC1C1C1</item>
<item>0xFFC1C100</item>
<item>0xFF00C1C1</item>
<item>0xFF00C100</item>
<item>0xFFC100C1</item>
<item>0xFFC10000</item>
<item>0xFF0000C1</item>
<item>0xFF696969</item>
<item>0xFF00FFFF</item>
<item>0xFFFFFF00</item>
<item>0xFF052550</item>
<item>0xFF36056D</item>
<item>0xFF0000FF</item>
<item>0xFFFF0000</item>
<item>0xFFC1C1C1</item>
<item>0xFF2B2B2B</item>
<item>0xFF050505</item>
<item>0xFFFFFFFF</item>
<item>0xFF050505</item>
<item>0xFF000000</item>
<item>0xFF050505</item>
<item>0xFF0A0A0A</item>
<item>0xFF050505</item>
<item>0xFF0D0D0D</item>
<item>0xFF050505</item>
<item>0xFF2b2b2b</item>
</integer-array>

<integer-array name="barscolors">
<item>0xFFC0C0C0</item>
<item>0xFFC0C000</item>
<item>0xFF00C0C0</item>
<item>0xFF00C000</item>
<item>0xFFC000C0</item>
<item>0xFFC00000</item>
<item>0xFF0000C0</item>
<item>0xFF0000C0</item>
<item>0xFF131313</item>
<item>0xFFC000C0</item>
<item>0xFF131313</item>
<item>0xFF00C0C0</item>
<item>0xFF131313</item>
<item>0xFFC0C0C0</item>
<item>0xFF00214C</item>
<item>0xFFFFFFFF</item>
<item>0xFF32006A</item>
<item>0xFF131313</item>
<item>0xFF090909</item>
<item>0xFF131313</item>
<item>0xFF1D1D1D</item>
<item>0xFF131313</item>
</integer-array>

<integer-array name="ebucolors">
<item>0xFFBFBFBF</item>
<item>0xFFBFBF00</item>
<item>0xFF00BFBF</item>
<item>0xFF00BF00</item>
<item>0xFFBF00BF</item>
<item>0xFFBF0000</item>
<item>0xFF0000BF</item>
<item>0xFF000000</item>
</integer-array>
</resources>

轉載

『貳』 如何實現 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的包名,可能你需要修改。
<?xml version="1.0" encoding="utf-8"?>

<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">

<intent-filter android:priority="1">

<action android:name="android.service.wallpaper.WallpaperService" />

</intent-filter>

<meta-data

android:name="android.service.wallpaper"

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

</service>

我們還必須在AndroidManifest.xml中增加下面的代碼:
<uses-feature

android:name="android.software.live_wallpaper"

android:required="true" >

</uses-feature>

到此我們的基本配置已經OK了。

『叄』 android動態壁紙怎麼實現的,就好比android手機的那個魚會游動的桌面,是一個軟體還是壁紙效果。

在菜單-壁紙-動態壁紙

『肆』 android 動態壁紙 怎麼設置

2.1及以下系統不支持動態壁紙,2.2系統聽說有一種支持動態的google
map,也就是說現在對動態壁紙還不支持。

『伍』 android 怎麼獲取手機桌面上的動態壁紙的

WallpaperManager wm = WallpaperManager.getInstance(this);
WallpaperInfo wallInfo = wm.getWallpaperInfo();
如果wallInfo != null 說明當前系統使用的是動態壁紙,你可以在那個wallInfo裡面獲得到你想要的信息,但是要設置動態壁紙的話是需要一定許可權的,有點麻煩,希望對你有幫助。

『陸』 安卓動態壁紙下載的動態壁紙被放置在哪裡找不到動態壁紙文件夾

是apk格式的,安裝後後就可以在動態壁紙裡面看到

『柒』 安卓如何設置動態壁紙

在安卓專區美化分類里下動態壁紙
按住主屏幕下動.
出現幾個選項.
選壁紙~動態壁紙.
然後選你下載了的動態壁紙按設置壁紙就OK.
只有安卓2.1的才可以哦.
謝謝採納

『捌』 android動態壁紙可以刪除嗎

按住您要刪除(如:有道詞典和天氣)的圖標不放,並將其拖到立即刪除垃圾面積; 另外,您可能需要關閉意外動態壁紙壁紙,因為在啟動大量的運行內存和XT300的RAM不夠高,要打開動態壁紙的穩定運行,然後運行相當權力,所以不建議使用動態壁紙的。

『玖』 安卓怎麼設置動態壁紙

按住主屏空白處不要放,選擇相應的壁紙即可,首先確認你的手機支持動態壁紙,在確認你的手機內有動態壁紙,實在不會的話就去豌豆莢下載個壁紙軟體,一鍵搞定

閱讀全文

與android動態壁紙相關的資料

熱點內容
青少年喝酒解壓辯論賽 瀏覽:171
android如何新建activity 瀏覽:737
ntp支持的認證演算法 瀏覽:710
想做快手主播需要什麼app 瀏覽:921
阿里雲伺服器如何轉賬戶 瀏覽:901
編譯器和解釋器實現技術完全不同 瀏覽:429
虐殺原形漢化補丁怎麼解壓 瀏覽:643
文件夾驗證失敗 瀏覽:635
python是用什麼軟體編程 瀏覽:247
java並發編程教程 瀏覽:319
江鈴寶典空調壓縮機工作時間過短 瀏覽:634
自製單片機玩具車 瀏覽:901
stm32單片機模塊電源電壓 瀏覽:187
pdf層次 瀏覽:735
電腦里找不到編譯器 瀏覽:843
明茨伯格pdf 瀏覽:443
把網頁存成pdf 瀏覽:268
如何對電腦的d盤加密 瀏覽:101
刀片式伺服器怎麼連接電腦 瀏覽:83
矩陣計算java 瀏覽:235