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)
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With