I don't what 开发者_运维百科to give any background to activity. When I leave this property blank, it gives me an error.
And I have tried using @null
as a value but it shows black background.
Can any one guide me, how to make it transparent?
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.
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.
精彩评论