How do I create a transparent Activity on Android?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
A transparent Activity is created by giving it a theme whose window background is transparent and whose content does not fully cover the screen. This is useful for overlay-style screens, permission explanations, or lightweight modal experiences, but it should be used carefully because the underlying activity remains visible.
Define a Transparent Theme
The core step is a theme with a transparent window background. In a classic XML-based Android app, that usually looks like this:
Then apply the theme in your manifest:
When this activity starts, the previous activity remains visible behind it.
Keep the Layout Transparent Too
The theme alone is not enough if the activity layout fills the screen with an opaque background. Your root view should stay transparent unless you intentionally want only part of the screen covered.
Example layout:
This creates a white card floating on top of the visible previous activity.
Consider Whether a Dialog or Bottom Sheet Is Better
A transparent activity can work, but it is not always the best tool. If the goal is a small overlay or confirmation screen, a DialogFragment or bottom sheet is often easier to reason about because it stays within the same activity stack.
Use a transparent activity when:
- the overlay deserves its own lifecycle
- you need separate intent entry points
- the screen behaves more like an independent task step
Otherwise, lighter UI containers are usually easier to maintain.
Launch and Dismiss It Cleanly
You launch it like any other activity:
Inside the transparent activity, keep dismissal explicit:
That keeps the navigation model predictable for both the user and the developer.
Understand Window Behavior
Transparency only affects what the user sees, not how the activity stack works. The transparent activity is still the foreground activity, so lifecycle callbacks, focus, back handling, and input all belong to it. Treat it like a real screen that happens to reveal content underneath, not like a passive visual effect.
Common Pitfalls
- Setting a transparent theme but leaving the root layout background opaque. That makes the activity look non-transparent even though the window is configured correctly.
- Using a transparent activity when a dialog or fragment would fit the UX better. Separate activities add lifecycle and navigation overhead.
- Assuming touches automatically pass through to the activity behind. They usually do not; the top activity still owns the interaction surface.
- Forgetting to test transitions and back navigation. Transparent activities can feel awkward if launch and dismissal are not deliberate.
- Relying on old translucency flags without checking current theme and window behavior on modern Android versions.
Summary
- A transparent activity needs both a transparent theme and a layout that does not hide the whole screen.
- Apply the theme in the manifest and keep the window background transparent.
- Use the pattern for overlay-style screens that truly benefit from their own activity lifecycle.
- Do not expect touch events to pass through automatically to the activity underneath.
- Consider a dialog or bottom sheet first if the UI does not need a separate activity.

