Issue
I have two activities in my app, one is the home.kt
and another is the about.kt
, for both screens I have different background color, in the home.kt
file I set the status bar color to background color.
rememberSystemUiController().setStatusBarColor(
MaterialTheme.colors.background, darkIcons = MaterialTheme.colors.isLight
)
When I move to about.kt
I again tried to match its color to background but the status bar keeps its original color which was set in home.kt
rememberSystemUiController().setStatusBarColor(
MaterialTheme.colors.surface, darkIcons = MaterialTheme.colors.isLight
)
//This piece is having no effect
Solution
In each activity, instead of using:
rememberSystemUiController().setStatusBarColor
,
set the statusbar color like this:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ComposePlaygroundTheme {
window?.setStatusBarColor(Color.Red.toArgb())
}
}
}
}
Answered By - Johann
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.