[英]Prevent statusbar to be shown over NavigationView in devices with Notch
I have an issue with my NavigationView
, when it's expanded the statusBar is shown in semitransparent color over it and i would hide it completely by still keeping notch support.我的
NavigationView
有问题,当它展开时,状态栏以半透明颜色显示在它上面,我会通过仍然保持缺口支持来完全隐藏它。
It looks like this now:现在看起来像这样:
I've tried to add我试图添加
android:fitsSystemWindows="false"
in my Activity but nothing chanded. android:fitsSystemWindows="false"
在我的活动中,但没有任何变化。
My styles.xml looks like this:我的styles.xml 看起来像这样:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorAccent</item>
<item name="primaryTextColor">#F4F4F6</item>
<item name="colorControlNormal">@color/colorAccent</item>
<item name="secondaryTextColor">#96000000</item>
<item name="recyclerViewTitleColor">#96000000</item>
<item name="navColor">#2948ff</item>
<item name="colorTurni">@color/blueLight</item>
<item name="varianti">@color/green</item>
<item name="blueDark">@color/blueDark</item>
<item name="backgroundCardColor">#FFFF</item>
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.App.BottomSheetDialog</item>
<item name="android:windowLayoutInDisplayCutoutMode">
shortEdges
</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
What i would reach is this:我要达到的是:
Activity.xml活动.xml
<androidx.drawerlayout.widget.DrawerLayout android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FAFAFA"
android:orientation="vertical"
tools:context="it.gabtamagnini.visualposmobile.PtermActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
...
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_menu"
android:layout_width="185dp"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
android:background="@color/white"
android:layout_gravity="start"
app:headerLayout="@layout/layout_header">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewMenu"
android:layout_width="match_parent"
android:layout_marginTop="120dp"
android:layout_height="match_parent"
tools:listitem="@layout/layout_menu"
android:clipToPadding="false"
android:paddingBottom="15dp"
android:paddingEnd="5dp"
android:paddingStart="5dp" />
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
This shadow is related to the drawable used for the inset foreground which is customized to R.styleable.ScrimInsetsFrameLayout_insetForeground
style by default on the NavigationView
;此阴影与用于嵌入前景的可绘制对象有关,默认情况下在
NavigationView
上自定义为R.styleable.ScrimInsetsFrameLayout_insetForeground
样式; this answer explains more about the ScrimInsetsFrameLayout
class.这个答案解释了有关
ScrimInsetsFrameLayout
类的更多信息。
Getting rid of this drawable from the NavigationView
either programmatically or in layout:以编程方式或布局从
NavigationView
中删除此可绘制对象:
Programmatically: setting setScrimInsetForeground
to null.以编程方式:将
setScrimInsetForeground
设置为 null。
navView.setScrimInsetForeground(null)
In layout: using app:insetForeground="@null"
:在布局中:使用
app:insetForeground="@null"
:
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_menu"
....
app:insetForeground="@null"/>
Use this in your NavigationView
not in activity
在您的
NavigationView
中使用它而不是在activity
中
android:fitsSystemWindows="false"
it will solve your issue它会解决你的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.