[英]facing problem in changing status bar color in jetpack compose
我的應用程序中有兩個活動,一個是home.kt
,另一個是about.kt
,對於兩個屏幕,我都有不同的背景顏色,在home.kt
文件中,我將狀態欄顏色設置為背景顏色。
rememberSystemUiController().setStatusBarColor(
MaterialTheme.colors.background, darkIcons = MaterialTheme.colors.isLight
)
當我移動到about.kt
我再次嘗試將其顏色與背景匹配,但狀態欄保持其在home.kt
中設置的原始顏色
rememberSystemUiController().setStatusBarColor(
MaterialTheme.colors.surface, darkIcons = MaterialTheme.colors.isLight
)
//This piece is having no effect
在每個活動中,而不是使用:
rememberSystemUiController().setStatusBarColor
,
使用這個(用你的背景顏色替換 0xff0000):
activity.window?.setStatusBarColor(0xff0000)
把它放在你的可組合中,這樣每次你的可組合重新組合時它都會被調用。
為此,谷歌也創建了一個名為伴奏的庫。 你可以在這里找到它: https : //github.com/google/accompanist
就像在這個模塊中有多個模塊用於jetpack compose,系統控制器,因此您可以使用它進行更改
如需更多了解,請參閱文檔:-- https://google.github.io/accompanist/systemuicontroller/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.