Thursday 8 May 2014

How to hide Action bar / Notification bar/ Status bar in Android | How to display activity in full screen

We saw in many games or another application that splash activity starts on full screen without status bar or anything. It’s very easy to implement this.
There are two sets of codes for android version 4.1 above and below. So I have put in If statement both codes.
Step-1: Copy and paste the below codes after setContentView() in onCreate(), whichever activity you want in full screen.

Code:

if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
       
        else{
              View decorView = getWindow().getDecorView();
              // Hide the status bar.
              int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
              decorView.setSystemUiVisibility(uiOptions);
              // Remember that you should never show the action bar if the
              // status bar is hidden, so hide that too if necessary.
              ActionBar actionBar = getActionBar();
              actionBar.hide();
        }

Step-2: After pasting this code will give some errors.Keep the mouse cursor on red and import relataed classes.. Your code will run.



1 comment:

  1. Casino Review 2021: Is It Worth Playing Online For Real Money
    It is one of the 영주 출장마사지 most popular 세종특별자치 출장안마 gambling websites at the moment. The 서귀포 출장샵 casino is operated by a single platform, and 강원도 출장마사지 it is licensed and 보령 출장안마 regulated by the UK Gambling

    ReplyDelete