Android Question Notification Bar text and icons colors

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

I have managed to change the notification bar and theme color thanks to this tutorial: https://www.b4x.com/android/forum/threads/theme-colors.87716/

My question is how to change the color of the text and icons in the notification bar? My app is white, and I would like the top items to be black on white, like the Gmail app:
_20190916_220055.JPG


Thank you for your help.
Jmon.

Edit: I would like to do the same for the bottom bar, with the triangle, home and square icons. Thanks
 

jmon

Well-Known Member
Licensed User
Longtime User
I found the solution from the Android Dev:
https://developer.android.com/reference/android/R.attr.html#windowLightStatusBar

I just add this to my manifest for API 23:
B4X:
<item name="android:windowLightStatusBar">true</item>
and there are more options for API 27, it can make the navigation bar too:
B4X:
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar">true</item>

Si this is my updated manifest code below. It makes the status bar white with dark text on API 23, and status bar & navigation bar white with dark text on API 27
B4X:
'Action bar and theme below
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">#ff000000</color>
   <color name="statusbar">#ffffffff</color>
   <color name="statusbardark">#ff000000</color>
   <color name="textColorPrimary">#ff000000</color>
   <color name="navigationBar">#ff000000</color>
</resources>
)
CreateResource(values-v27, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:colorPrimaryDark">@color/statusbar</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:navigationBarColor">@color/statusbar</item>  
        <item name="android:windowLightStatusBar">true</item>
        <item name="android:windowLightNavigationBar">true</item>
    </style>  
</resources>
)
CreateResource(values-v23, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:colorPrimaryDark">@color/statusbar</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:navigationBarColor">@color/navigationBar</item>  
        <item name="android:windowLightStatusBar">true</item>
    </style>  
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:colorPrimaryDark">@color/statusbardark</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:navigationBarColor">@color/navigationBar</item>
    </style>  
</resources>
)
CreateResource(values-v14, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Holo.Light">
       <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
    </style>
   <style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
       <item name="android:background">@color/actionbar</item>
   </style>
</resources>
)

I have only android 7 phone, so I can only confirm that it works for API 23 and below. Anyone could confirm the API 27 and above if you can? I cannot see the navigation bar on the AVD. Thanks
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User

Attachments

  • NavColor2.zip
    9 KB · Views: 210
Upvote 0
Top