如何创建一个背景透明的activity

来源:互联网 发布:25岁还能长高么 知乎 编辑:程序博客网 时间:2024/04/30 10:20

有如下步骤:

1在style.xml中一个主题

<resources>          <style name="TransparenceTheme">          <item name="android:windowBackground">@color/transparent_background</item>          <item name="android:windowNoTitle">true</item>          <item name="android:windowIsTranslucent">true</item>            <item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>

2在colors.xml中新建一个颜色

<?xml version="1.0" encoding="utf-8"?>      <resources>        <color name="transparent_background">#50000000</color> </resources>  

3.在manifest中,制定的activity中,引用新的主题

<activity                  android:name="com.michael.transparenceactivitydemo.TransparenceActivity"                  android:theme="@style/TransparenceTheme"/></activity >
0 0
原创粉丝点击