In the development of Android applications, we will encounter some interface settings to the full screen display format, there are two ways to achieve. One is implemented in Java code, and the other is implemented in the configuration file.
1. Set in Java code
Super. oncreate (savedinstancestate); requestwindowfeature (window. feature_no_title); // No titlegetwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); // setcontentview (R. layout. main );
Note that the two Java codes must be placed before setcontentview (); otherwise, an error is reported. The error is shown as follows.
[Plain]View
Plaincopy
- 01-14 05:25:41. 429: E/androidruntime (7405): caused by: Android. util. androidruntimeexception: requestfeature () must be called before adding content
2. modify it in the manifest File
Add Android: theme = "@ Android: style/theme. notitlebar. fullscreen" to the default activity.
[HTML]View
Plaincopy
- <Activity Android: Name = ". mainactivity"
- Android: Label = "@ string/app_name"
- Android: theme = "@ Android: style/theme. notitlebar. fullscreen"
- >
- <Intent-filter>
- <Action Android: Name = "android. Intent. Action. Main"/>
- <Category Android: Name = "android. Intent. Category. launcher"/>
- </Intent-filter>
- </Activity>