androidandroid-fragmentsandroid-toolbarandroid-titlebar

Hide Statusbar in fragment


I'm trying to hide status bar in fragment. I have successfully hidden toolbar but I want to hide status bar also only in one fragment..

  @Override
    public void onCreate(Bundle arg0) {
        super.onCreate(arg0);

   // requestWindowFeature(Window.FEATURE_NO_TITLE);

        ((HomeActivity)getActivity()).getSupportActionBar().hide();
    }

Above code working fine for hide toolbar

  requestWindowFeature(Window.FEATURE_NO_TITLE);

If I requestWindowFeature in fragment onCreate (has mentioned above) application was crashed.

Added three screenshots after implementing answer by @Mathan Chinna

  1. Normal Screen

Normal Screen

  1. After implementing the code from @Mathan Chinna

code from mathan chinna

  1. When I come back from full screen

When I come back from full screen


Solution

  • @Lalit Singh Fauzdar answer to hide statusBar is correct. if u want to show statusBar u can use

    View decorView = getActivity().getWindow().getDecorView(); // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
    decorView.setSystemUiVisibility(uiOptions);