zoukankan      html  css  js  c++  java
  • Android学习笔记---设置Activity透明显示

    在styles.xml里面加入以下属性

        <style name="TranslucentTheme">
            <item name="android:windowBackground">@color/transparent2</item>
            <item name="android:colorBackgroundCacheHint">@null</item>
            <item name="android:windowIsTranslucent">true</item>
            <item name="android:windowAnimationStyle">@style/Translucent_NoTitle</item>
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowContentOverlay">@null</item>
        </style>
    
    
        <style name="Translucent_NoTitle" parent="android:style/Theme.Dialog">
            <item name="android:windowNoTitle">true</item>
            <item name="android:background">#00000000</item>
            <item name="android:windowBackground">@android:color/transparent</item>
            <item name="android:colorBackgroundCacheHint">@null</item>
            <item name="android:windowIsTranslucent">true</item>
        </style>

    最后在AndroidManifest.xml里引用即可

    <activity
                android:theme="@style/TranslucentTheme"
                android:name="com.anjoyo.adapplication.MainActivity"
                android:label="ad" >
                <intent-filter>
                     <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    <style name="TranslucentTheme">
    <item name="android:windowBackground">@color/transparent2</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowAnimationStyle">@style/Translucent_NoTitle</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    </style>


    <style name="Translucent_NoTitle" parent="android:style/Theme.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="android:background">#00000000</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    <item name="android:windowIsTranslucent">true</item>
    </style>
  • 相关阅读:
    第一章:linux命令初步
    请教shell读写XML问题(转)
    讓 BootCamp 下的 Windows XP 也能有 D 硬碟槽(转)
    Linux下的多线程编程(转)
    怎么查看redhat版本
    不透過 Boot Camp 安裝 Windows 7,並切割成多個磁碟槽(转)
    同位语从句用法详解
    更改linux的最大文件描述符限制
    ObjectiveC中 copy, tetain, assign , readonly , readwrite, nonatomic区别
    Linux如何查找文件安装路径
  • 原文地址:https://www.cnblogs.com/langfei8818/p/7605452.html
Copyright © 2011-2022 走看看