透明状态栏/系统UI在4.4 Kit Kat上的设置

30

这在4.4版本中应该是可行的,但我还没有找到相关的文档 - 有人知道如何使状态栏/system-ui透明/半透明吗?

3个回答

98

使用内置主题之一将导致您无法拥有一个ActionBar

半透明系统栏

现在,您可以使用新的主题Theme.Holo.NoActionBar.TranslucentDecorTheme.Holo.Light.NoActionBar.TranslucentDecor来部分透明化系统栏。通过启用半透明的系统栏,您的布局将填充系统栏后面的区域,因此您还必须为布局的不应被系统栏覆盖的部分启用fitsSystemWindows

如果您正在创建自定义主题,请将这些主题设置为父主题之一,或在您的主题中包含windowTranslucentNavigationwindowTranslucentStatus样式属性。

如果您希望在使用操作栏的同时具有透明状态栏和透明导航栏,则只需在自定义主题(在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>

45
+1是因为你写了这篇内容,我可以直接复制/粘贴! - Stephane Mathis
仅为澄清,此适用于API Level 19+。 - Joshua Pinter

23

请看这里 - http://developer.android.com/about/versions/android-4.4.html#UI

半透明系统栏

现在,你可以使用新的主题Theme.Holo.NoActionBar.TranslucentDecor和Theme.Holo.Light.NoActionBar.TranslucentDecor使系统栏变成半透明。启用半透明系统栏后,你的布局将填充系统栏后面的区域,所以你必须为那些不被系统栏覆盖的部分启用fitsSystemWindows。

如果你正在创建自定义主题,将其中一个主题设置为父主题或包含windowTranslucentNavigation和windowTranslucentStatus样式属性。


9

我还没有找到相关的文档

嗯...

http://developer.android.com/about/versions/kitkat.html#44-immersive

为了让内容更具冲击力,您现在可以使用新的窗口样式和主题来请求半透明的系统UI,包括状态栏和导航栏。为了确保导航栏按钮或状态栏信息的可读性,在系统栏后面显示微妙的渐变。一个典型的用例是需要向壁纸展示的应用程序。

http://developer.android.com/about/versions/android-4.4.html#UI

现在,您可以使用新主题Theme.Holo.NoActionBar.TranslucentDecor和Theme.Holo.Light.NoActionBar.TranslucentDecor来使系统栏部分半透明。通过启用半透明的系统栏,您的布局将填充系统栏后面的区域,因此您还必须启用fitsSystemWindows以便布局中不应被系统栏覆盖的部分。
如果您正在创建自定义主题,请将其中一个主题设置为父主题或在您的主题中包含windowTranslucentNavigation和windowTranslucentStatus样式属性。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接