Android - Making activity full screen with status bar on top of it

Utshaw picture Utshaw · Apr 20, 2017 · Viewed 53.2k times · Source

I want to make my activity full screen with status bar on top of it like this picture:

enter image description here

I have used this code in manifest inside activity tag:

'android:theme="@style/Theme.AppCompat.Light.NoActionBar"'

But my view doesn't start from the status bar & it looks like this:

enter image description here

How can I make my activity look like the first one?

Answer

Vishwajit Palankar picture Vishwajit Palankar · Mar 27, 2018

I know that the guy asking the question may have found his own solution but for the people who are still looking for a solution this is a very simple solution but one thing it has a limitation till Kitkat so a condition is added

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                      WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}