NavigationView
扩展了ScrimInsetsFrameLayout
,该布局侦听窗口插图更改并向布局添加了暗线。ScrimInsetsFrameLayout
相同具有可定义样式属性insetForeground
,至少在com.google.android.material:material:1.1.0-alpha07
中存在。 <item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@color/transparent</item>
insetForeground
设置为 @color/transparent
即可。<com.google.android.material.navigation.NavigationView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:insetForeground="@color/transparent"/>
警告:
如果您设置了android:fitsSystemWindows="true"
,此方法将无效。
注意: 使用此方法意味着您必须手动处理插图,因为您正在使用半透明状态而不是适应系统窗口。
NavigationView
,如果你使用FrameLayout
,你可以通过使用半透明状态栏和android:windowDrawsSystemBarBackgrounds
来实现这个效果。不过你需要手动处理插图。 - Alpha