kanytu / android-material-drawer-template

An Android template with navigation drawer for material design
Apache License 2.0
674 stars 217 forks source link

Navigation RecyclerView items offset after full screen #33

Closed TJCC closed 9 years ago

TJCC commented 9 years ago

First of all let me say thank you for this code. It works great!

In my app I have the need to set full screen using:

if (Global.prefFullScreen && Build.VERSION.SDK_INT >= 18) {
            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 // hide nav bar
                            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            getSupportActionBar().hide();
        } else if (Global.prefFullScreen) {
            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 // hide nav bar
                            | View.SYSTEM_UI_FLAG_FULLSCREEN);// hide status bar
            getSupportActionBar().hide();
        }

Everything works fine but when I exit full screen

mDecorView.setSystemUiVisibility(0);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        getSupportActionBar().show();

the navigation items have a little gap at the top and do not sit under the action bar as when it starts.

This is what it looks like when the app starts up and everything is OK before full screen

and this is what it looks like after the full screen after full screen

I cannot figure out where and when or what to change. Can you help me out?

Cheers, Tim

kanytu commented 9 years ago

Hello there:

Go to fragment_navigation_drawer.xml and remove:

android:fitsSystemWindows="true"

Hope this helps :)

TJCC commented 9 years ago

Awesome! Works great. Thank you.