Android ApiDemos示例解析(18):App->Activity->Wallpaper

Wallpaper介紹一個Activity如何通過Style把系統Wallpaper作為當前Activity的背景。

這是WallpaperActivity在AndroidManifest.xml中的定義:

<activity android:name=”.app.WallpaperActivity”
android:label=”@string/activity_wallpaper”
android:theme=”@style/Theme.Wallpaper”>
<intent-filter>
< action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.SAMPLE_CODE” />
< /intent-filter>
< /activity>

@style/Theme.Wallpaper定義如下:繼承系統android:style/Theme.Wallpaper,並將前景色設為白色(這裡是文字的顏色)

<!– A theme that has a wallpaper background.  Here we explicitly specify
that this theme is to inherit from the system’s wallpaper theme,
which sets up various attributes correctly. –>
<style name=”Theme.Wallpaper” parent=”android:style/Theme.Wallpaper”>
<item name=”android:colorForeground”>#fff</item>
< /style>

 


作者:mapdigit
 

發佈留言