现在的位置: 首页 > 综合 > 正文

可以通过在AndroidManifest.xml中指定Activity的theme制定某些特性

2018年03月20日 ⁄ 综合 ⁄ 共 1275字 ⁄ 字号 评论关闭

可以通过在AndroidManifest.xml中指定Activity的theme制定某些特性
例如,半透明效果,
        <activity android:name=".app.TranslucentActivity"
                android:label="@string/activity_translucent"
                android:theme="@style/Theme.Translucent">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>

theme在styles.xml有如下定义,
    <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>
注意style使用了继承了android预定义的类型android:style/Theme.Translucent"

以上是半透明效果,透明效果如下所示,
<style name="Theme.Transparent">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
        <item name="android:windowBackground">@drawable/transparent_background</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:colorForeground">#fff</item>
    </style>

 还可以指定系统的墙纸作为Activity的背景。
    <style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper">
        <item name="android:colorForeground">#fff</item>
    </style>

 

抱歉!评论已关闭.