如果Activity是透明背景,则能够看到其跳转过来的Activity,如桌面,或者是一个父Activity.
需要特别指出的是,Activity背景透明与控件的背景透明不太一样,对于控件,只要设置其属性android:background="#80xxxxxx"就可以了,这里的80就是Alpha的属性值,00表示完全透明,ff表示不透明。当然了,其实如果将Activity中的最大的Layout设置为透明也能达到类型的效果。
这里有两种方法实现Activity的透明背景。
1. 使用android内置的透明样式:
在AndroidManifest.xml中的<activity>标签中添加
2. 使用自定义的透明样式:
(1). res/values下建colors.xml文件:
(2). res/values/下建styles.xml:
在AndroidManifest.xml中的任意<activity>标签中添加
需要特别指出的是,Activity背景透明与控件的背景透明不太一样,对于控件,只要设置其属性android:background="#80xxxxxx"就可以了,这里的80就是Alpha的属性值,00表示完全透明,ff表示不透明。当然了,其实如果将Activity中的最大的Layout设置为透明也能达到类型的效果。
这里有两种方法实现Activity的透明背景。
1. 使用android内置的透明样式:
在AndroidManifest.xml中的<activity>标签中添加
android:theme="@android:style/Theme.Translucent"
其中,android:style/Theme.Translucent是android内置的透明样式
2. 使用自定义的透明样式:
(1). res/values下建colors.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<color name="transparent">#9000</color>
</resources>
这个值设定了整个界面的透明度,为了看得见效果,现在设为透明度为56%(9/16)左右。
(2). res/values/下建styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Transparent">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
</resources>
(3). 设置andrdoi:theme:
在AndroidManifest.xml中的任意<activity>标签中添加
android:theme="@style/transparent"