0

Many answers I saw said try adding <item name="android:windowLightStatusBar">true</item>,
but my status bar font color isn't changed from white whether I set true or false. (default color is white).
I added this line in .../res/values/themes/themes.xml and themes.xml(night).

I don't care it will be deleted or transparentized. Just want to make it invisible.
Like this : enter image description here
What should I do now? Someone help please?
If you need more detailed information, please comment! thank you!

my code is here (themes.xml) :

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.NewProject" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/black</item>
        <item name="colorPrimaryVariant">@color/black</item>
        <item name="colorOnPrimary">@color/black</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor">?attr/colorPrimaryDark</item>
        <!-- Customize your theme here. -->
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <!-- ** Added Line ** -->
        <item name="android:windowLightStatusBar">true</item>
    </style>
</resources>
yooooonly
  • 9
  • 5

1 Answers1

0

Add the following in your style to customize the status-bar color

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.NewProject" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/black</item>
        <item name="colorPrimaryVariant">@color/black</item>
        <item name="colorOnPrimary">@color/black</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>

        <!-- Customize your theme here. -->
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>

        <!-- ** Add here ** -->
        <!-- ** if you prefer no status bar use this ** -->
        <item name="android:statusBarColor" tools:targetApi="l">@android:color/transparent</item>
    </style>
</resources>

Edit:

// use this to display no text in toolbar
getSupportActionBar().setDisplayShowTitleEnabled(false);
Sekiro
  • 1,537
  • 1
  • 7
  • 21
  • In my directory, I haven't had `styles.xml` that I had seen many questions related to this topic. But I found the `styles.xml` and `.../res/values/themes/themes.xml` have similar contents. So I edited `themes.xml` but it's not working, I added the line you added though. Is the directory a problem? If it's true, ShouId I add the `styles.xml` in `.../res/values` and the `themes.xml` is deleted? – yooooonly Jan 17 '21 at 15:28
  • @yooooonly I meant the same, add that in your `themes.xml`, check the edited answer now it's working in my device – Sekiro Jan 17 '21 at 15:34
  • After pasting, It's not working too. My purpose is [this](https://i.stack.imgur.com/dvW8n.jpg). The text is not deleted in status bar. I thought my project's setting might have some problem, so I tried a new project, but it wasn't solved, too. – yooooonly Jan 17 '21 at 15:58
  • @yooooonly if you prefer no title in your toolbar, just add the edited answer in your activity class and leave the themes undisturbed – Sekiro Jan 17 '21 at 16:12