18

I am developing one android application which use transparent activity.. I used the following link as reference but my problem is when i set background color as black i am not able see previous. i need transparent like this .

alt text

Thanks in Advance...

Community
  • 1
  • 1
David
  • 2,079
  • 2
  • 21
  • 29

2 Answers2

34

Try setting your background color to somewhat transparent, i.e. #55000000 or '#5000'. Create colors.xml in your res/values folder:

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <color name="background">#55000000</color>
</resources>

Then use the color in your theme style:

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <style name="YourTheme" parent="android:@Theme.Translucent">
           <item name="android:windowBackground">@color/background</item>
     </style>
</resources>

Key thing here is to set Theme.Translucent as parent of your style, I've tried same with Theme.Light and that didn't work.

Konstantin Burov
  • 68,322
  • 16
  • 114
  • 93
34

I had requirements to do the same thing in My Application, and I tried the above solution but unfortunately it didn't work for me.

After searching a lot for the same Issue, I have found one another solution That I would like to share here,

I have one Demo.java activity for top and Test.java Activity to show in background..So for that I have created one Style and applied to Demo.java ...and Magic..All Worked.!!

style.xml

<style name="Theme.D1NoTitleDim" parent="android:style/Theme.Translucent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">@android:color/transparent</item>
</style>

and in Manifest.xml

<activity android:name="Demo"
android:theme="@style/Theme.D1NoTitleDim"></activity>

Hope This will help Others Too. Enjoy Coding.!!

Chirag Patel
  • 2,310
  • 3
  • 24
  • 38
  • 1
    Thanks this is just what I needed! – vm204 Mar 06 '12 at 16:22
  • 1
    thank you.. i dont need to create the new same question.... :D this is what I needed.... – andikurnia Mar 29 '12 at 08:28
  • thanks this worked like a charm ... but how do you get out from the default color ? Like here for the background you are using @android:color/transparent ... but lets say that I want a purplish background ... how do i get this color ? – Rakeeb Rajbhandari Aug 25 '13 at 03:49