简体   繁体   English

Android编程:如何在Android Nougat中使导航栏完全透明

[英]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.

相关问题 Android - 完全透明的状态栏,带有非透明导航栏 - Android - Fully transparent status bar with non transparent navigation bar Android 11 (API 30) 中的导航栏不完全透明 - Navigation bar is not fully transparent in Android 11 (API 30) 如何在 Android Jetpack Compose 中使导航栏透明? - How to Make Navigation Bar Transparent in Android Jetpack Compose? Android:完全向上滚动后如何更改状态栏颜色,然后在开始向下滚动时再次使其透明 - Android : How to change the status bar color after scrolling fully up and then again make it transparent on start scrolling down 使 Android 通知栏透明而不是底部导航栏 - Make Android Notification Bar Transparent Not Bottom Navigation Bar 如何创建一个完全透明的导航栏? - How to create a fully transparent Navigation Bar? 如何在 android 工作室中使用 java 使 android 中的状态栏和底部导航透明? - How to make status bar and bottom navigation transparent in android using java in android studio? Android X 中的透明导航栏 - Transparent navigation bar in Android X 如何使导航栏透明 - How to make the navigation bar transparent Android:如何设置状态栏和导航栏半透明 - Android: How to set status bar and navigation bar semi transparent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM