[英]How to change status bar icons color in Android?
您实际上不能像那样更改 android 中的状态栏图标颜色。 您仍然可以将状态栏颜色更改为您想要的任何颜色,但对于状态栏图标,只有 2 个选项 - 浅色(白色)或深色(灰色)。
如果你想使用白色图标,那么只需将<item name="android:windowLightStatusBar">false</item>
属性放在你的基本应用程序主题中。 对于深色图标<item name="android:windowLightStatusBar">true</item>
您也可以像这里提到的那样以编程方式进行 - https://stackoverflow.com/a/39596725/10357086
在 kotlin 中,您可以使用以下几行
// for white color of status bar
val window = this.window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = ContextCompat.getColor(this, R.color.white)
WindowCompat.getInsetsController(window, window.decorView).apply {
isAppearanceLightStatusBars = true
}
// for other color of status bar
val window = this.window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = ContextCompat.getColor(this, R.color.other_color)
WindowCompat.getInsetsController(window, window.decorView).apply {
isAppearanceLightStatusBars = false
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.