Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Translucent status bar with Inverted icons

I was wondering how one could achieve Google Calendar's look.enter image description here

That is:

  • Inverted status bar icons
  • Custom status bar color(that is not the default color transparency set by windowTranslucentStatus)
  • Widgets top padding adjusted to be under the status bar

What I've tried:

Setting windowTranslucentStatus disables windowLightStatusBar:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowTranslucentStatus">true</item>

Allows full transparency only(no colors in between), fitSystemWindows doesn't work properly:

<item name="android:windowLightStatusBar">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#19000000</item>

window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)

Thanks.

like image 790
Andre Romano Avatar asked Jul 19 '17 15:07

Andre Romano


2 Answers

Managed to find the solution:

onCreate (in Kotlin):

window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.statusBarColor = Color.parseColor("#1A000000")

styles.xml:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
like image 87
Andre Romano Avatar answered Oct 10 '22 17:10

Andre Romano


Fixed this by setting all the flags programmatically. Apparently, for some weird reason setting the windowsLightStatusBar in styles wasn't reflecting.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setNavigationBarColor(getResources().getColor(R.color.colorAccentDark));
        //getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
        //setStatusBarTranslucent(true);
    }
like image 20
Bezaleel Avatar answered Oct 10 '22 16:10

Bezaleel