Lollipop draw behind statusBar with its color set to transparent
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The Android operating system introduced significant changes in its user interface with the release of Android 5.0 Lollipop. One of the more notable features was the ability for applications to draw behind the status bar and make it transparent, providing a more immersive and aesthetically pleasing user experience. This feature is particularly useful for apps with rich visual content, such as games, full-screen videos, or photograph-based applications.
Technical Explanation
Drawing Behind the Status Bar
Before Lollipop, Android apps typically extended only up to the status bar. This was because the status bar — showing system information such as battery life, time, and notifications — was opaque and always visible in its default state. Lollipop introduced more sophisticated capabilities to manage the status and navigation bar, allowing apps to render content behind it.
Setting Status Bar to Transparent
To draw behind the status bar and make it transparent in Lollipop and later versions, developers need to use the Window and System UI flags. Here's a step-by-step guide:
- Set the Status Bar Transparent: To achieve transparency, apply the following flags in your activity:
SYSTEM_UI_FLAG_LAYOUT_STABLE: Ensures that the system bars are always visible.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN: Allows the layout to be drawn full-screen.
- Content Legibility: Ensure that content such as text or icons is readable against varied background images.
- Gesture Conflicts: Consider how this might interfere with swipe gestures associated with system UI.
- Use this feature to show full-screen previews of photos without any UI obstructions.
- Provide an immersive environment by letting the artwork fill the entire screen.
- Apps with animated headers can extend the visual effect into the status bar area for a seamless transition.
- Rendering: Ensure that rendering transparent sections does not impact the performance in terms of battery usage and processing power.
- Versions: Not all devices may support these features if they are running versions prior to Lollipop. Developers might want to include version checks or fallbacks.

