Android中设定透明Activity的一点说明

来源:互联网 发布:如何制作淘宝网店图片 编辑:程序博客网 时间:2024/06/03 21:17

【参考】http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android

在 res/values/styles.xml 中设置属性如下:

<?xml version="1.0" encoding="utf-8"?><resources>  <style name="Theme.Transparent" parent="android:Theme">    <item name="android:windowIsTranslucent">true</item>    <item name="android:windowBackground">@android:color/transparent</item>    <item name="android:windowContentOverlay">@null</item>    <item name="android:windowNoTitle">true</item>    <item name="android:windowIsFloating">true</item>    <item name="android:backgroundDimEnabled">false</item>  </style></resources>

(the value @color/transparent is the color value #00000000 which I put in res/values/color.xml file. You can also use @android:color/transparent in later Android versions)

Then apply the style to your activity, for example:

<activity android:name=".SampleActivity" android:theme="@style/Theme.Transparent">...</activity>
0 0
原创粉丝点击