I am developing an Android application using Jetpack Compose.
I wanted to add Side Navigation Drawer. Which is working fine. But One Problem I am facing is the status bar is just spoiling the game.
So I wanted to make a status bar like OpenAI ChatGPT officially made and build using Jetpack Compose.
My Approach
-
I have added
WindowCompat.setDecorFitsSystemWindows(window, false)
so that I can customized as per my choice. -
My theme File Content
<style name="Theme.JetpackComposePlayGround" parent="Theme.Material3.Light.NoActionBar"> <item name="android:statusBarColor">@color/purple_700</item> </style>
My Output
It look ugly white
2
Answers
You can use this code to acheive the same behaviour
Then invoke it in
MainActivity.OnCreate()
, belowsetContent
function.Actually, it’s not a transparent status bar, it’s just filled with the proper color defined in the app theme.
With Jetpack Compose you could change the statusBar color globally in a custom Theme by adding the following lines:
The whole code:
Example is on my public GitHub repo . Hoping it would help