views:

61

answers:

2

dear friends,

i dont what to give any background to activity when i leave this propery blank it gives me error

and i have tried using @null as a value but it shows black background.

can any one guide how to make it transparent??

+1  A: 

For an Activity you can set the theme to translucent in the onCreate method:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
setTheme(android.R.style.Theme_Translucent);}

You could also do this in the xml file like in this tutorial.

Maurits Rijk
it is trasnparent but showing white background can i change that transparent background to some other color or black??
UMMA
As its translucent it will be clear but whatever activity is in the background is what you will see underneath
Donal Rafferty
yes you are right but i want previous activity then tranparent background between both and new activity.mean i could see through black transparent color previous activity.any idea??
UMMA
I'm sorry but I dont understand what you mean?You want to start a new activity over yand activity you already have on screem and be able to see through this new activity?
Donal Rafferty
+1  A: 

You should do this using styles. In res/values/styles.xml, have a theme definition:

<style name="MyTheme">
  <item name="android:background">@android:color/transparent</item>
  <item name="android:windowIsFloating">true</item>
</style>

As far as I know, you must set windowIsFloating, otherwise the runtime will not draw a translucent background (presumably for performance reasons... but I have seen this behavior change between different platform releases, so you could first try without it).

Then set the theme for your Activity in the manifest:

<activity android:name="..." android:theme="@style/MyTheme" ... />

That should do the job.

Matthias