如何摆脱DrawerLayout顶部和底部的这些黑色透明条?

时间:2016-09-18 19:28:39

标签: android android-layout android-theme android-fullscreen

我实现了沉浸式模式,除了我的Android应用程序的NavigationView / DrawerLayout部分外,我的Activity中没有问题。

我如何摆脱这些障碍 - 我已经尝试过使用windowTranslucentBar,适合系统窗口但是还没有能够摆脱它。

编辑:我的xml布局的相关部分

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawer_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:openDrawer="start">

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="340dp"
    android:layout_height="match_parent"
    android:background="@color/backgroundColorPrimary"
    android:layout_gravity="start"
    app:headerLayout="@layout/nav_header_main"
    app:itemBackground="@color/backgroundColorPrimary"
    app:itemIconTint="@color/foregroundColorPrimary"
    app:itemTextColor="@color/foregroundColorPrimary">
    <include layout="@layout/nav_side_bar"/>
 </android.support.design.widget.NavigationView>

编辑:我如何启用沉浸式模式

@Override
public void onWindowFocusChanged(boolean hasFocus) {
  super.onWindowFocusChanged(hasFocus);
  if (hasFocus) {
    mDecorView.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
  }
}

0 个答案:

没有答案