StatusBarUtil
A util for setting status bar style on Android App.
StatusBarUtil is a small Android library that lets you set the color, transparency, or icon style of the Android status bar with a single method call, working back to Android 4.4.
StatusBarUtil is a small Android library that makes it easier to style the status bar, the thin strip at the top of an Android phone screen that shows the time, battery level, and notifications. By default Android gives developers limited control over this area, and the rules changed between Android versions. This library smooths that out and works back to Android 4.4 (KitKat).
You add it to a project with a single Gradle dependency and then call static methods from your Activity or Fragment code. The available options include setting the status bar to a specific color, making it translucent with a chosen alpha level, making it fully transparent, and switching between light mode (dark icons) and dark mode (light icons). There are also methods for specific layout situations that need extra handling, such as screens that use a navigation drawer, screens where a full-bleed image sits behind the status bar, and screens built with Fragments inside a ViewPager.
For fragments and image header layouts, the library inserts a placeholder view that takes up the same height as the status bar so content does not slide underneath it unexpectedly. There is also a method specifically for swipe-back pages, intended for use alongside swipe-to-dismiss gesture libraries. The alpha value for translucency can be adjusted between 0 and 255 depending on how opaque you want the status bar tint to appear.
The project includes a sample app demonstrating each feature and screenshots in the README showing how each setting looks on a real device. It is licensed under the Apache License 2.0.
Where it fits
- Set a custom status bar color to match your app's toolbar without writing per-API-level boilerplate code.
- Make the status bar fully transparent so a hero image or gradient extends behind it on a detail screen.
- Switch the status bar to light mode so dark icons are visible against a light-colored top area.
- Handle status bar styling correctly on screens with a navigation drawer or a full-bleed image header.