[英]Android Programming: How to make navigation bar fully transparent in Android Nougat
I want to make the navigation bar fully transparent in my app. 我想使导航栏在我的应用程序中完全透明。 I have tried the other answers, but they only make the status bar fully transparent and the navigation bar still has a dark half-transparent color.
我尝试了其他答案,但是它们只能使状态栏完全透明,而导航栏仍具有深色的半透明颜色。 Here is my code:
这是我的代码:
styles.xml: styles.xml:
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
Activity.java: Activity.java:
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Here is the result I'm trying to get: goal 这是我想要得到的结果: 目标
and here is the result I'm currently getting: result 这是我当前得到的结果 : 结果
Is there any way to achieve a fully transparent navigation bar? 有什么方法可以实现完全透明的导航栏?
Try to set <item name="android:android:windowTranslucentStatus">true</item>
set android:statusBarColor
to @android:color/transparent
. 尝试将
<item name="android:android:windowTranslucentStatus">true</item>
设置为android:statusBarColor
到@android:color/transparent
。
Then add code below: 然后在下面添加代码:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
If you also want the navigation bar to be translucent, set android:navigationBarColor
to @android:color/transparent
and combine the flag View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
as well. 如果您还希望导航栏是半透明的,请将
android:navigationBarColor
设置为@android:color/transparent
并同时组合标志View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
。
Try it may it will work. 尝试它可能会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.