1

I use this code to make an activity full screen

requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_read);

How to I make the activity not full screen again, by a press of a button??

Eddie
  • 171
  • 5
  • 13

2 Answers2

3

If u change the height and width replace the values u want .8 and .85 in this code

    DisplayMetrics dm=new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width=dm.widthPixels;
    int height=dm.heightPixels;
    getWindow().setLayout((int)(width*.8),(int)(height*.85));

Note: the values not exceed 1

Raj
  • 477
  • 5
  • 20
0

use this functions to go/hide Immersive Full-Screen Mode

 View mDecorView = getWindow().getDecorView();

 private void hideSystemUI() {
    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);
}

    private void showSystemUI() {
    mDecorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

more here: https://developer.android.com/training/system-ui/immersive.html

Dan Alboteanu
  • 9,404
  • 1
  • 52
  • 40