简体   繁体   English

透明背景

[英]Transparent Background

How can i make the background 50% transparent? 如何使背景50%透明?
Let's say the background of an AbsoluteLayout so it's dark but you can still see through it? 让我们说一个AbsoluteLayout的背景,所以它是黑暗但你仍然可以看透它?

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM