4

How can I create a translucent activity on top of my activity to show help contents? I've seen many apps showing help content over a translucent screen(like when a spinner dropdown is shown, the rest of the screen goes dim and the drop down is projected. I want to create that dim screen)

Jonik
  • 80,077
  • 70
  • 264
  • 372
Sachin Murali G
  • 575
  • 6
  • 25
  • possible duplicate of [Translucent Activity filling the entire screen](http://stackoverflow.com/questions/10481277/translucent-activity-filling-the-entire-screen) – Snicolas Dec 08 '13 at 08:53
  • pls don't close, due to extra value provided in accepted answer - the "flash" is a problem with transparent screens, and this shows how to fix that problem. – Richard Le Mesurier Jan 29 '14 at 11:35

2 Answers2

6

Just set the appropriate theme to your activity in your AndroidManifest.xml:

<activity android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">

You could set the theme in onCreate() of your activity, but you will see a black flickering for the time between the setup of the activity.

flx
  • 14,146
  • 11
  • 55
  • 70
  • 1
    Perfect solution to avoid flickering between activity transition........You could set the theme in onCreate() of your activity, but you will see a black flickering for the time between the setup of the activity. – Android_IT Jan 14 '14 at 09:00
5

Declare your activity in manifest like this:

<activity android:name=".yourActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>

and add a transparent background to your layout.

To avoid black flickering you should disable activity animation by creating a style:

<style name="noAnimTheme" parent="android:Theme">
  <item name="android:windowAnimationStyle">@null</item>
</style>

then in manifest set it as theme for activity or whole application.

<activity android:name=".ui.yourActivity" android:theme="@style/noAnimTheme">
</activity>

Or just specify Intent.FLAG_ACTIVITY_NO_ANIMATION flag when starting activity.

Plo_Koon
  • 2,953
  • 3
  • 34
  • 41