Full screen / Immersive application in Android Studio

Jeff Prado
2 min readMay 31, 2020

--

As every beginner, I started getting guided by the documentation of Android Studio which is very helpful.

http://developer.android.com

Somehow, I get involved in the need of develop a full screen app. That’s why I decided to explain very explicit and step by step what you will need to get it.

Normal app
Full screen app

Basically, what we must do is explained in the previous Android documentation I mentioned, so let’s take a look of it:

So, what we have is:

· onWindowsFocusChanged detects every time If you gain window focus, you may want to re-hide the system bars by calling hideSystemUI

· hideSystemUI change the systemUiVisibility to enable the full screen flags

· showSystemUI show the system bars

The simplest way is to add this code to every activity you want to display on full screen mode, but a better way is to create your custom activity which will be the parent of the rest.

Our custom activity has to be an open class so we can extend from it later and obviously it has to extend from AppCompatActivity.

To optimize code lines I decided to create a constant value with the flags we will need.

Then on the onCreate function we call our fullScreencall where is the logic for the full screen mode

The onResume should call it too for better UX.

fullScreencall is the function where we set the full screen mode accordingly the SDK version of the device, if it is between 11 and 19 the machine set GONE to systemUiVisibility. On the other hand, for versions after 19th all the machine does is to set the full screen flags.

As I explained with the code provided by Android documentation, onWindowFocusChanged will detect when the focus changes and it will set the flags for the screen mode again

Then the only step we have to do is to extend from our MasterActivity like this:

class AnotherActivity: MasterActivity()

There we go, you will have a full screen app. THANKS FOR READING

--

--