aryaxt aryaxt - 4 months ago 62
Android Question

Transparent Background

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?


You could apply a transparent theme to the required activity. Create a new style in /res/values/style.xml

<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>

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.

<activity android:name="MyActivity" android:theme="@style/Transparent"></activity>