Android Question B4A 13.7 SDK 36 and the navigation bar icons color

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all!

I recently installed B4A version 13.7 and have a question regarding a non-B4XPages application. When I open the app on a Samsung S23+, the status bar is almost invisible and the icons are white. See Screen1. Is it possible to change the color of these icons or make them more visible? I mean - is it possible to change the color of these 3 icons to black to make them look like on screen2?

I need to keep the system bar background white.

This is my manifest

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="36"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:allowBackup, "false")
'CreateResourceFromFile(Macro, Themes.LightTheme)
'Non-SSL permission
CreateResourceFromFile(Macro, Core.NetworkClearText)
'End of default text.

'AddPermission (android.permission.WRITE_EXTERNAL_STORAGE)
'AddPermission (android.permission.READ_EXTERNAL_STORAGE)

'    FusedLocationProvider:

'    required manifest entry required for Google Play Services
AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
SetActivityAttribute(MessageDetails, android:windowSoftInputMode, adjustPan|stateHidden)
'Firebase
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.Crashlytics)

AddPermission(com.google.android.gms.permission.AD_ID)


'34
'AddPermission(android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING)
'SetServiceAttribute(FirebaseMessaging, android:foregroundServiceType, "remoteMessaging") - Service
'SetServiceAttribute(Starter, android:foregroundServiceType, "remoteMessaging") 'Receiver

'36
'SetApplicationAttribute(android:enableOnBackInvokedCallback, "false")
SetApplicationAttribute(android:enableOnBackInvokedCallback, "true")
'
SetApplicationAttribute(android:theme, "@style/LightTheme")

CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">@android:color/transparent</color>
</resources>
)

CreateResource(values, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:windowActionBarOverlay">true</item>
    </style>
</resources>
)

Thank you.
 

Attachments

  • screen1.jpg
    screen1.jpg
    16.7 KB · Views: 54
  • screen2.jpg
    screen2.jpg
    11.7 KB · Views: 50
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can make the status bar icons dark by setting <item name="android:windowLightStatusBar">true</item>.

This snippet is from the default Theme.LightTheme:

B4X:
CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
        <item name="android:windowLightStatusBar">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)

Example of setting the colors programmatically with edge to edge: https://www.b4x.com/android/forum/t...ammatically-with-edge-to-edge.171763/#content
It shouldn't be too difficult to adopt it to non-B4XPages.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
You can make the status bar icons dark by setting <item name="android:windowLightStatusBar">true</item>.

This snippet is from the default Theme.LightTheme:

B4X:
CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
        <item name="android:windowLightStatusBar">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)

Example of setting the colors programmatically with edge to edge: https://www.b4x.com/android/forum/t...ammatically-with-edge-to-edge.171763/#content
It shouldn't be too difficult to adopt it to non-B4XPages.
Thank you.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
You can make the status bar icons dark by setting <item name="android:windowLightStatusBar">true</item>.

This snippet is from the default Theme.LightTheme:

B4X:
CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
        <item name="android:windowLightStatusBar">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)

Example of setting the colors programmatically with edge to edge: https://www.b4x.com/android/forum/t...ammatically-with-edge-to-edge.171763/#content
It shouldn't be too difficult to adopt it to non-B4XPages.
I tried to modify my manifest with this example - it doesn't work. I might be doing something wrong


B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="36"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:allowBackup, "false")
'CreateResourceFromFile(Macro, Themes.LightTheme)
'Non-SSL permission
CreateResourceFromFile(Macro, Core.NetworkClearText)
'End of default text.

'AddPermission (android.permission.WRITE_EXTERNAL_STORAGE)
'AddPermission (android.permission.READ_EXTERNAL_STORAGE)

'    FusedLocationProvider:

'    required manifest entry required for Google Play Services
AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
SetActivityAttribute(MessageDetails, android:windowSoftInputMode, adjustPan|stateHidden)
'Firebase
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.Crashlytics)

AddPermission(com.google.android.gms.permission.AD_ID)


'34
'AddPermission(android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING)
'SetServiceAttribute(FirebaseMessaging, android:foregroundServiceType, "remoteMessaging") - Service
'SetServiceAttribute(Starter, android:foregroundServiceType, "remoteMessaging") 'Receiver

'36
SetApplicationAttribute(android:enableOnBackInvokedCallback, "true")

SetApplicationAttribute(android:theme, "@style/LightTheme")
'
'CreateResource(values, colors.xml,
'<resources>
'    <color name="actionbar">@android:color/transparent</color>   
'</resources>
')
'
'CreateResource(values, theme.xml,
'<resources>
'    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
'        <item name="android:colorPrimary">@color/actionbar</item>
'        <item name="android:windowActionBarOverlay">true</item>        '       
'    </style>
'</resources>
')

CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
        <item name="android:windowLightStatusBar">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)

The navigation bar icons are white and the navigation bar is also white.

But it works with this code - the navigation bar is white and the icons are black.

B4X:
Public Sub SetStatusNavigationBarColor(Root As B4XView,Color As Int,DarkText As Boolean)
    
    Try

        
        Dim p As Phone
        If p.SdkVersion >= 21 Then
            Dim jo As JavaObject
            jo.InitializeContext
            Dim window As JavaObject = jo.RunMethodJO("getWindow", Null)
            window.RunMethod("addFlags", Array (0x80000000))
            window.RunMethod("clearFlags", Array (0x04000000))
            window.RunMethod("setStatusBarColor", Array(Color))
            window.RunMethod("setNavigationBarColor", Array(Color))
        End If
        If p.SdkVersion >= 23 Then
            jo = Root
            If DarkText Then
                jo.RunMethod("setSystemUiVisibility",Array(8192+16))
            Else
                jo.RunMethod("setSystemUiVisibility",Array(0x00000010))
            End If
        End If
    Catch
        Log("SetStatusNavigationBarColor " & LastException.Message)
        ShowError("modFun_SetStatusNavigationBarColor " & LastException.Message)
    End Try
End Sub

Thank you.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
This is a bug. Fix is here: https://www.b4x.com/android/forum/t...t-macros-fix-for-light-navigation-bar.171792/

You can remove the theme related calls from the manifest editor and keep:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)

This can also be removed:
B4X:
SetApplicationAttribute(android:enableOnBackInvokedCallback, "true")
It is now set by default.
Is my manifest correct now?

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="36"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:allowBackup, "false")
'Non-SSL permission
CreateResourceFromFile(Macro, Core.NetworkClearText)
'End of default text.

'AddPermission (android.permission.WRITE_EXTERNAL_STORAGE)
'AddPermission (android.permission.READ_EXTERNAL_STORAGE)

'    FusedLocationProvider:

'    required manifest entry required for Google Play Services
AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
SetActivityAttribute(MessageDetails, android:windowSoftInputMode, adjustPan|stateHidden)
'Firebase
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.Crashlytics)

AddPermission(com.google.android.gms.permission.AD_ID)

SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
        <item name="android:windowLightStatusBar">true</item>
        <item name="android:windowLightNavigationBar">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Holo.Light">
    </style>
</resources>
)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Remove:
B4X:
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
        <item name="android:windowLightStatusBar">true</item>
        <item name="android:windowLightNavigationBar">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Holo.Light">
    </style>
</resources>
)

Add:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)

You can also remove:
B4X:
AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
It is included in GooglePlayBase macro.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Remove:
B4X:
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values-v20, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Material.Light">
       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
        <item name="android:windowLightStatusBar">true</item>
        <item name="android:windowLightNavigationBar">true</item>
    </style>
     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
        <item name="android:textAllCaps">false</item>
    </style>
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
    <style
        name="LightTheme" parent="@android:style/Theme.Holo.Light">
    </style>
</resources>
)

Add:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)

You can also remove:
B4X:
AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
It is included in GooglePlayBase macro.
Like this?


B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="36"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:allowBackup, "false")
'Non-SSL permission
CreateResourceFromFile(Macro, Core.NetworkClearText)
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

'AddPermission (android.permission.WRITE_EXTERNAL_STORAGE)
'AddPermission (android.permission.READ_EXTERNAL_STORAGE)

'    FusedLocationProvider:

'    required manifest entry required for Google Play Services
'AddApplicationText(<meta-data
'    android:name="com.google.android.gms.version"
'    android:value="@integer/google_play_services_version" />)
SetActivityAttribute(MessageDetails, android:windowSoftInputMode, adjustPan|stateHidden)
'Firebase
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.Crashlytics)

AddPermission(com.google.android.gms.permission.AD_ID)

'SetApplicationAttribute(android:theme, "@style/LightTheme")
'CreateResource(values-v20, theme.xml,
'<resources>
'    <style
'        name="LightTheme" parent="@android:style/Theme.Material.Light">
'       <item name="android:actionMenuTextAppearance">@style/LowerCaseMenu</item>
'        <item name="android:windowLightStatusBar">true</item>
'        <item name="android:windowLightNavigationBar">true</item>
'    </style>
'     <style name="LowerCaseMenu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu">
'        <item name="android:textAllCaps">false</item>
'    </style>
'</resources>
')
'CreateResource(values-v14, theme.xml,
'<resources>
'    <style
'        name="LightTheme" parent="@android:style/Theme.Holo.Light">
'    </style>
'</resources>
')
 
Upvote 0
Top