-2

In my application I want set transparent background to statusBar and set white color to statusBar icons.

I write below codes and set transparent background to statusBar and navigationBar .

But I want just set transparent background to statusBar (not navigationBar) and change statusBar icons color from black to white.

Style codes:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="AppTheme" parent="Theme.AppCompat.DayNight">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimary21</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:colorBackground">@color/white</item>

        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">false</item>
    </style>
</resources>

Java codes:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    Window w = getWindow();
    w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

And set this flag to rootLayout : android:fitsSystemWindows="true"

my codes result is :

How can I fix it? please help me enter image description here

Akshay Katariya
  • 1,464
  • 9
  • 20
RedBounce
  • 213
  • 5
  • 14

1 Answers1

-1

You can use this:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().setStatusBarColor(getResources().getColor(R.color.ransparent_color_resource));
    }

Hope this helps.