apidemo 学习 android 实现透明activity

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值