Eddie
Eddie

Reputation: 181

How to make an activity not full screen

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??

Upvotes: 1

Views: 1456

Answers (2)

Dan Alboteanu
Dan Alboteanu

Reputation: 10232

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

Upvotes: 0

Raj
Raj

Reputation: 487

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

Upvotes: 3

Related Questions