我想在另一个活动之上创建一个透明的活动。
I want to create a transparent Activity on top of another activity.
我怎样才能做到这一点?
How can I achieve this?
添加下面的样式在你的 RES /价值/ styles.xml
文件(如果你不这样做有一个,创建一个)下面是一个完整的文件:
Add the following style In your res/values/styles.xml
file (if you don’t have one, create it.) Here’s a complete file:
<?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>
(数值 @色/透明
的颜色值#00000000
我放在 RES /价值/ color.xml 文件您也可以使用 @android:彩色/透明
在以后的Android版本)
(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>