Search code examples
androidandroid-layoutandroid-toolbarandroid-theme

android - how to remove darkness from status bar


I've darkness in my status bar and I want to remove it . I've removed status and toolbar color to replace it with a gradient color

these are my codes :

<style name="AppTheme.TransparentTheme">
    <item name="android:navigationBarColor">@android:color/transparent</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>

in my code :

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS );

the result is this :


Solution

  • You can use this code for that particular screen where you want to remove dark color and also the color you want to show. Place this code after setContentView in that class

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            // clear FLAG_TRANSLUCENT_STATUS flag:
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(getResources().getColor(R.color.Your_color));
    
     to change the same color in the navigation bar
    
    window.setNavigationBarColor(@ColorInt int color)
        }
    

    Try this and let me know.