带半透明图标的Android半透明状态栏

And*_*ano 5 android android-design-library

我想知道如何才能获得Google日历的外观。在此处输入图片说明

那是:

  • 反转状态栏图标
  • 自定义状态栏颜色(不是windowTranslucentStatus设置的默认颜色透明度)
  • 小部件顶部填充已调整为在状态栏下

我尝试过的

设置windowTranslucentStatus会禁用windowLightStatusBar:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowTranslucentStatus">true</item>
Run Code Online (Sandbox Code Playgroud)

只允许完全透明(中间没有颜色),fitSystemWindows无法正常工作:

<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)
Run Code Online (Sandbox Code Playgroud)

谢谢。

And*_*ano 7

设法找到解决方案:

onCreate(在 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")
Run Code Online (Sandbox Code Playgroud)

样式.xml:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
Run Code Online (Sandbox Code Playgroud)