https://kotlinlang.org logo
#compose-android
Title
# compose-android
y

Yusuf Ibragimov

03/19/2024, 5:33 AM
Hi everyone, I have one question about controlling my status bar's icon color. I have two types of screens, one is a white background and the second has a black background. How do I control my status bar's icons' tint color based on my screen navigation, or is there any tool that detects colors based on background color.
s

Stylianos Gakis

03/19/2024, 6:13 AM
There is no automatic tool per se, but material at least handles this with LocalContentColor. If your top app bar is part of your screen, and your screen at the root level is specifying a component which sets up the LocalContentColor for you, like
Surface
, or you just do it yourself, you can then just use LocalContentColor and that should be it. If not using material you gotta create something similar yourself.
k

Kirill Grouchnikov

03/19/2024, 3:09 PM
By “my status bar” do you mean a part of your app, or the system status bar up top with the notification icons, current time, battery status icon etc?
s

Stylianos Gakis

03/19/2024, 3:21 PM
Oh you are totally right, I understood the top app bar but they probably mean the OS status bar. Can look into this https://developer.android.com/reference/androidx/activity/EdgeToEdge and how that does things. Before there used to be https://google.github.io/accompanist/systemuicontroller/ as well if you only need the color stuff without the edge to edge part. You can look at that implementation and copy-paste the right parts to use them too.