1

I know this question asked many time and I tested solutions which provide but none of them works. I want to hide StatusBar and Toolbar so I use following code to hide statusBar base on documentation:

 int flags = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

 getWindow().getDecorView().setSystemUiVisibility(flags);

And this code for showing statusBar:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);

It's works but When I hide statusBar my darkPrimaryColor is still visible like following pic (I use fade Animation with Translate for hiding Toolbar)

enter image description here

I also set fit android:fitsSystemWindows="false" But in this case oolbar goes behind statusBar.

I also see this thread but solution not work because I'm using drawerLayout as root.

Here is my layout:

 <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        tools:openDrawer="start">

        <android.support.design.widget.CoordinatorLayout
            android:id="@+id/root">

            <android.support.design.widget.AppBarLayout
                android:id="@+id/appbar">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar" />

            </android.support.design.widget.AppBarLayout>

            <include layout="@layout/view_epg_player" />

        </android.support.design.widget.CoordinatorLayout>
    <android.support.v4.widget.DrawerLayout/>

Also try following code which green status-bar are disappear But it's not smooth and still looking for better approach, without causing a layout jerk.

Hide status-bar:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

Show status-bar

 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Community
  • 1
  • 1
Amir
  • 16,067
  • 10
  • 80
  • 119

0 Answers0