倒立图标的Android半透明状态栏
问题描述:
我想知道如何实现Google日历的外观。 倒立图标的Android半透明状态栏
即:
- 倒立状态栏图标
- 自定义状态栏的颜色(不是默认颜色透明度windowTranslucentStatus设置)
- 窗口小部件的顶部填充调整到状态栏下
我已经试过:
设置windowTranslucentStatus禁用windowLightStatusBar:
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowTranslucentStatus">true</item>
允许充分的透明度,只在(之间没有颜色),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)
感谢。
答
是的,你可以更改状态栏图标颜色为黑色。新增这个在你的价值观-V23/styles.xml
<item name="android:windowLightStatusBar">true</item>
eg.add在style.xml给你的价值观V23夹
<?xml version="1.0" encoding="utf-8"?>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">#F5F5F5</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowLightStatusBar">true</item>
</style>
请务必更改colorPrimaryDark在V23/styles.xml为灰色或white.it从API 23
答
工作你可以试试这个。在值-V23添加此和您的布局设置这个主题
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:statusBarColor">#fff</item>
<item name="android:windowLightStatusBar">true</item>
</style>
这将状态栏背景变为白色
<item name="android:statusBarColor">#fff</item>
这将改变状态栏图标颠倒(灰色)
<item name="android:windowLightStatusBar">true</item>
答
设法找到了解决方案:
的onCreate(在科特林):
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>
答
以编程方式设置所有的标志修正这一点。显然,由于一些奇怪的原因,在样式中设置windowsLightStatusBar并没有反映出来。
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);
}
只设置该选项不会产生图片中的结果 –