Android 透明背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3114675/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Transparent Background
提问by aryaxt
How can i make the background 50% transparent?
Let's say the background of an AbsoluteLayout so it's dark but you can still see through it?
如何使背景透明 50%?
假设 AbsoluteLayout 的背景很暗,但您仍然可以看穿它?
回答by Primal Pappachan
You could apply a transparent theme to the required activity. Create a new style in /res/values/style.xml
您可以将透明主题应用于所需的活动。在 /res/values/style.xml 中创建新样式
<resources>
<style name="Transparent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
<item name ="android:windowBackground">@color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:colorForeground">#fff</item>
</style>
</resources>
The value of transparent is
透明的价值是
<color name="transparent">#00000000</color>
Now in AndroidManifest.xml declare the theme of the activity to the one you just created.
现在在 AndroidManifest.xml 中将活动的主题声明为您刚刚创建的主题。
<activity android:name="MyActivity" android:theme="@style/Transparent"></activity>