Android Question How to change color of status bar icons and color of navigation bar items?

Lucas Siqueira

Active Member
Licensed User
Longtime User
I can change the text colors and icons in the status bar with the following code.
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethodJO("getWindow", Null).RunMethodJO("getDecorView",Null). _ 
RunMethod("setSystemUiVisibility", Array(0x00002000)) 'ICONS DARK STATUS BAR

I can also change the colors of the navigation bar icons with the following code.
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethodJO("getWindow", Null).RunMethodJO("getDecorView",Null). _ 
RunMethod("setSystemUiVisibility", Array(0x08000000)) 'ICONS LIGHT NAVIGATION BAR

but when I try to use both codes together, only the last code that is applied, how can I change both?
B4X:
Dim jo As JavaObject
jo.InitializeContext

jo.RunMethodJO("getWindow", Null).RunMethodJO("getDecorView",Null). _ 
RunMethod("setSystemUiVisibility", Array(0x00002000)) 'ICONS DARK STATUS BAR

jo.RunMethodJO("getWindow", Null).RunMethodJO("getDecorView",Null). _ 
RunMethod("setSystemUiVisibility", Array(0x08000000)) 'ICONS LIGHT NAVIGATION BAR

1623322771359.png
 

roumei

Active Member
Licensed User
You overwrite setSystemUiVisibility with the second call. You can add the constants and set the result once. Please note that this method is deprecated in API level 30.
List of constants: https://developer.android.com/reference/android/view/View#SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethodJO("getWindow", Null).RunMethodJO("getDecorView",Null). _
RunMethod("setSystemUiVisibility", Array(0x00002000 + 0x00000010))
 
Upvote 0
Top