During development, we often need to set our applications to full screen. Here I know two methods. One is to set them in code, another way is to change it in the configuration file!
1. Set in the Code:
[Java]
View plaincopy
- Package com. Android. tutor;
- Import Android. App. activity;
- Import Android. OS. Bundle;
- Import Android. View. window;
- Import Android. View. windowmanager;
- Public class opengl_lesson1 extends activity {
- Public void oncreate (bundle savedinstancestate ){
- Super. oncreate (savedinstancestate );
- // No title
- Requestwindowfeature (window. feature_no_title );
- // Full screen
- Getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen,
- Windowmanager. layoutparams. flag_fullscreen );
- Setcontentview (R. layout. Main );
- }
- }
It should be emphasized that the full screen code must be before setcontentview (R. layout. Main), or an error will be reported.
2. modify it in the configuration file (Android: theme = "@ Android: style/theme. notitlebar. fullscreen "):
[Java]
View plaincopy
- <? XML version = "1.0" encoding = "UTF-8"?>
- <Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
- Package = "com. Android. Tutor"
- Android: versioncode = "1"
- Android: versionname = "1.0" type = "codeph" text = "/codeph">
- <Application Android: icon = "@ drawable/icon" Android: Label = "@ string/app_name">
- <Activity Android: Name = ". opengl_lesson1"
- Android: theme = "@ Android: style/theme. notitlebar. fullscreen"
- Android: Label = "@ string/app_name">
- <Intent-filter>
- <Action Android: Name = "android. Intent. Action. Main"/>
- <Category Android: Name = "android. Intent. Category. launcher"/>
- </Intent-filter>
- </Activity>
- </Application>
- <Uses-SDK Android: minsdkversion = "7"/>
- </Manifest>
Here I would like to explain that the former will see a short status bar after we run the application, and then the full screen will be displayed. This is not the case in the second method, so I suggest