<activity
android:name=".app.TranslucentActivity"
android:label="@string/activity_translucent"
android:theme="@style/Theme.Translucent" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity> <!-- A theme that has a translucent background. Here we explicitly specify
that this theme is to inherit from the system's translucent theme,
which sets up various attributes correctly. -->
<style name="Theme.Translucent" parent="android:style/Theme.Translucent">
<item name="android:windowBackground">@drawable/translucent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">#fff</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="@string/translucent_background" />
背景是壁纸的activity
<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> <!-- 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>

本文详细介绍了如何在Android应用中为特定活动设置透明白色背景和壁纸背景的主题样式,包括代码实现、XML布局文件的使用以及关键属性的配置。
1421

被折叠的 条评论
为什么被折叠?



