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,103
  • 3
  • 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,980
  • 16
  • 115
  • 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.!!

And you must make the following changes in the target activity (let's say splash activity):

public class SplashScreenActivity extends Activity {}

Be sure to extend it to the activity

tfih313
  • 3
  • 4
Chirag Patel
  • 2,320
  • 3
  • 24
  • 38
  • 1
    thank you.. i dont need to create the new same question.... :D this is what I needed.... – caknia 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