Android Question How to change the text color in statusbar

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone my app has a very light color as primary color and the text in the statusbar is not visible anymore because it is white.
I wish to set it to dark in order to be readable

Screenshot_2023-09-06-10-40-03-44_f2886aca08f44d168dfcebeb455ded76.jpg


This is my Manifest, i tried different combination of themes, but maybe i'm not doing the right thing.
B4X:
SetApplicationAttribute(android:theme, @style/CustomTheme)
CreateResource(values, theme.xml,
<resources>
  <style name="CustomTheme" parent="@android:style/Theme.Material.Light">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowBackground">#E3EAFF</item>
  <!--<item name="android:windowContentOverlay">@null</item>-->
  <!--<item name="android:windowNoTitle">true</item>-->
  <item name="android:backgroundDimEnabled">true</item>
  <!--<item name="android:windowFullscreen">true</item>-->
 
  <item name="android:colorPrimary">#E3EAFF</item>                 <!-- action bar -->
  <item name="android:colorPrimaryDark">#E3EAFF</item>             <!-- status bar -->
  <item name="android:colorAccent">#001040</item>                 <!-- Seekbar,, checkboxes,, switches,, etc. -->
 
  <item name="android:textColorPrimary">#001040</item>             <!-- ? -->
  <item name="android:textColorSecondary">#CCCCCC</item>         <!-- inactive editText line,, scrollbar -->
  <item name="android:textColor">#001040</item>                 <!-- menu text,, msgbox title -->
  <item name="android:textColorLink">#b71c1c</item>
  <item name="android:textColorHighlight">#FF9F9F</item>
</style>
</resources>
)

I already tried this, and this by @Erel but in that case he changes the color from code, instead i'm doing everything from the manifest.
In 2023 (Android 13) what is the right way?

Thanks in advance
 
Solution
Why not change it programmatically?
Because conceptually I see it something more "Manifest related", and I prefer to not include AppCompat just for a text color and use the standard Android theme options

I ended up using this line in the theme, it works fine.
B4X:
<item name="android:windowLightStatusBar">true</item>

Entire theme code:
B4X:
SetApplicationAttribute(android:theme, @style/CustomTheme)
CreateResource(values, theme.xml,
<resources>
  <style name="CustomTheme" parent="@android:style/Theme.Material.Light">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowBackground">#E3EAFF</item>
  <!--<item name="android:windowContentOverlay">@null</item>-->
  <!--<item...

Mike1970

Well-Known Member
Licensed User
Longtime User
Yes, this is the first link I took a look at, and I tried using the Material theme, but the ui in the statusbar is still white.
I tried changing the Material.Light to Material.Dark but i got an error saying that it could not be found.

I saw that below there is an example using AppCompat, but actually i was thinking there was a "faster" and lighter way to change a text color without import a whole library.

P.S. I did not undestand what is the value to change for the statusbar text color in the AppCompat anyway... the first four are the same of the Material theme, the last three does not seems to have something to do with the statusbar.
:confused:
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Why not change it programmatically?
Because conceptually I see it something more "Manifest related", and I prefer to not include AppCompat just for a text color and use the standard Android theme options

I ended up using this line in the theme, it works fine.
B4X:
<item name="android:windowLightStatusBar">true</item>

Entire theme code:
B4X:
SetApplicationAttribute(android:theme, @style/CustomTheme)
CreateResource(values, theme.xml,
<resources>
  <style name="CustomTheme" parent="@android:style/Theme.Material.Light">
  <item name="android:windowIsTranslucent">true</item>
  <item name="android:windowBackground">#E3EAFF</item>
  <!--<item name="android:windowContentOverlay">@null</item>-->
  <!--<item name="android:windowNoTitle">true</item>-->
  <item name="android:backgroundDimEnabled">true</item>
  <!--<item name="android:windowFullscreen">true</item>-->
  <item name="android:windowLightStatusBar">true</item>
 
  <item name="android:navigationBarColor">#00E3EAFF</item>
 
 
  <item name="android:colorPrimary">#00E3EAFF</item>                 <!-- action bar -->
  <item name="android:colorPrimaryDark">#00E3EAFF</item>             <!-- status bar -->
  <item name="android:colorAccent">#001040</item>                 <!-- Seekbar,, checkboxes,, switches,, etc. -->
 
  <item name="android:textColorPrimary">#001040</item>             <!-- ? -->
  <item name="android:textColorSecondary">#CCCCCC</item>         <!-- inactive editText line,, scrollbar -->
  <item name="android:textColor">#001040</item>                 <!-- menu text,, msgbox title -->
  <item name="android:textColorLink">#b71c1c</item>
  <item name="android:textColorHighlight">#FF9F9F</item>
 

</style>
</resources>
)
 
Upvote 0
Solution
Top