Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change statusbar color in jetpack compose?

how to make status bar color transparent in compose like here:

enter image description here

it has the same color but with a little bit shade.

like image 792
Nurseyit Tursunkulov Avatar asked Jan 07 '21 10:01

Nurseyit Tursunkulov


People also ask

How do I change the text color in jetpack?

To change color of Text composable in Android Jetpack Compose, pass a required Color value for the optional color parameter of Text composable.

How do I change the color of my notification bar?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.

How do you change the bar color in flutter?

Step 1: Locate the MaterialApp widget. Step 2: Inside the MaterialApp, add the theme parameter with ThemeData class assigned. Step 3: Inside the ThemeData add the appBarTheme parameter and then assign the AppBarTheme class. Step 4: Inside the AppBarTheme , specify the systemOverlayStyle parameter and set the color.

Is jetpack compose stable now?

Today, we're releasing version 1.2 of Jetpack Compose, Android's modern, native UI toolkit, continuing to build out our roadmap.


2 Answers

Google has just created a library called accompanist.
You can find it here: https://github.com/google/accompanist

It contains multiple helpful libraries for Jetpack Compose, among which is a System UI Controller that you can use for changing the status bar color.

Docs - https://google.github.io/accompanist/systemuicontroller/

like image 146
Donny Rozendal Avatar answered Sep 23 '22 14:09

Donny Rozendal


Step 1 (add dependency) => version may change

implementation "com.google.accompanist:accompanist-systemuicontroller:0.17.0" 

Step 2 => inside theme.kt file

change the colors according to your need in the functions below.

val systemUiController = rememberSystemUiController() if(darkTheme){     systemUiController.setSystemBarsColor(         color = Color.Transparent     ) }else{     systemUiController.setSystemBarsColor(         color = Color.White     ) } 

Step 3 => ON systemUiController you can acces all types of customizations u need for you app above one is a sample for setSystemBarsColor

like image 31
dolar Avatar answered Sep 21 '22 14:09

dolar