How to set up an Activity to take up all screen space?

Asked

Viewed 290 times

1

I want to hide to the notification bar!!

1 answer

2

To occupy every screen you have two options:

1 - By theme

Just use/inherit the theme @android:style/Theme.NoTitleBar.Fullscreen. Remembering that you won’t have the ActionBar, can use the Toolbar to fill that gap.

2 - Programmatically

Just make the request to remove the title and set the flag’s of Fullscreen to Window:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);

Remembering that it is necessary to perform this excerpt after the call to super.onCreate and before the setContentView. Otherwise it will fail due to the presence of content.

I believe the first option is more elegant, can be softer than the second.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.