简体   繁体   English

如何使导航栏透明

[英]How to make the navigation bar transparent

How can I make the navigation bar transparent on Android 4.4.X and above? 如何在Android 4.4.X及更高版本上使导航栏透明?

I have searched in the documentation, but found nothing about this. 我在文档中搜索过,但没有发现任何相关信息。

I have taken this from the change log for Android KitKat (4.4) : 我从Android KitKat(4.4)的更改日志中获取了这个:

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 . 现在,您可以使用新主题( Theme.Holo.NoActionBar.TranslucentDecorTheme.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. 通过启用半透明系统栏,您的布局将填充系统栏后面的区域,因此您还必须为布局中不应被系统栏覆盖的部分启用fitsSystemWindows

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. 如果要创建自定义主题,请将其中一个主题设置为父主题,或在主题中包含windowTranslucentNavigationwindowTranslucentStatus样式属性。

Hope this helps get you started. 希望这有助于您入门。

I used your trevor-e's answer, by creating a custom theme in my styles.xml 我使用你的trevor-e的答案,在styles.xml中创建一个自定义主题

<style name="Theme.HomeScreen" parent="android:Theme.Holo.NoActionBar.TranslucentDecor">
 <item name="android:windowBackground">@android:color/transparent</item>
             <item name="android:windowNoTitle">true</item> 
        </style>

and then you can set the theme from the manifest 然后你可以从清单中设置主题

<activity
            android:name="MyActivity" 
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.HomeScreen" >
     </activity> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM