Android 透明状态栏 / system-ui on 4.4 Kit Kat
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20167755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
transparent status-bar / system-ui on 4.4 Kit Kat
提问by ligi
This must be possible with 4.4, but I found no documentation on this yet - anyone knows how to make the status-bar / system-ui transparent/translucent ?
这在 4.4 中必须是可能的,但我还没有找到关于此的文档-有人知道如何使状态栏/系统用户界面透明/半透明吗?
采纳答案by Joel Fernandes
Here you go - http://developer.android.com/about/versions/android-4.4.html#UI
给你 - http://developer.android.com/about/versions/android-4.4.html#UI
Translucent system bars
You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the parent theme or include the windowTranslucentNavigation and windowTranslucentStatus style properties in your theme.
半透明系统栏
您现在可以使用新主题 Theme.Holo.NoActionBar.TranslucentDecor 和 Theme.Holo.Light.NoActionBar.TranslucentDecor 使系统栏部分半透明。通过启用半透明系统栏,您的布局将填充系统栏后面的区域,因此您还必须为布局中不应被系统栏覆盖的部分启用 fitsSystemWindows。
如果您要创建自定义主题,请将这些主题之一设置为父主题或在您的主题中包含 windowTranslucentNavigation 和 windowTranslucentStatus 样式属性。
回答by NPike
Using one of the built-in themes precludes you from having an ActionBar
.
使用其中一个内置主题会使您无法拥有ActionBar
.
Translucent system bars
You can now make the system bars partially translucent with new themes,
Theme.Holo.NoActionBar.TranslucentDecor
andTheme.Holo.Light.NoActionBar.TranslucentDecor
. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enablefitsSystemWindows
for the portion of your layout that should not be covered by the system bars.If you're creating a custom theme, set one of these themes as the parent theme or include the
windowTranslucentNavigation
andwindowTranslucentStatus
style properties in your theme.
半透明系统栏
您现在可以使用新主题使系统栏部分半透明,
Theme.Holo.NoActionBar.TranslucentDecor
并且Theme.Holo.Light.NoActionBar.TranslucentDecor
. 通过启用半透明系统栏,您的布局将填充系统栏后面的区域,因此您还必须启用fitsSystemWindows
不应被系统栏覆盖的布局部分。如果您正在创建自定义主题,请将这些主题之一设置为父主题或在您的主题中包含
windowTranslucentNavigation
和windowTranslucentStatus
样式属性。
If you wish to have transparent status bar, and transparent navigation with the use of an Action Bar - then simply add the following to your custom theme (in values-v19/styles.xml)
如果您希望使用操作栏具有透明状态栏和透明导航 - 那么只需将以下内容添加到您的自定义主题中(在 values-v19/styles.xml 中)
<style name="Theme.MyTheme" parent="Theme.MyTheme.Base">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
回答by CommonsWare
I found no documentation on this yet
我还没有找到这方面的文档
Hmmmm...
嗯...
http://developer.android.com/about/versions/kitkat.html#44-immersive
http://developer.android.com/about/versions/kitkat.html#44-immersive
To get the most impact out of your content, you can now use new window styles and themes to request translucent system UI, including both the status bar and navigation bar. To ensure the legibility of navigation bar buttons or status bar information, subtle gradients is shown behind the system bars. A typical use-case would be an app that needs to show through to a wallpaper.
为了让您的内容产生最大的影响,您现在可以使用新的窗口样式和主题来请求半透明的系统 UI,包括状态栏和导航栏。为了确保导航栏按钮或状态栏信息的易读性,系统栏后面会显示微妙的渐变。一个典型的用例是需要显示墙纸的应用程序。
http://developer.android.com/about/versions/android-4.4.html#UI
http://developer.android.com/about/versions/android-4.4.html#UI
You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the parent theme or include the windowTranslucentNavigation and windowTranslucentStatus style properties in your theme.
您现在可以使用新主题 Theme.Holo.NoActionBar.TranslucentDecor 和 Theme.Holo.Light.NoActionBar.TranslucentDecor 使系统栏部分半透明。通过启用半透明系统栏,您的布局将填充系统栏后面的区域,因此您还必须为布局中不应被系统栏覆盖的部分启用 fitsSystemWindows。
如果您要创建自定义主题,请将这些主题之一设置为父主题或在您的主题中包含 windowTranslucentNavigation 和 windowTranslucentStatus 样式属性。