The full screen setting in the Android program includes two parts: window full screen and A ctivity full screen.
Window full screen is the title bar used to hide time, power, signal, and other information at the top of the system. A cti full screen is the title bar of the hidden program. You can set it in the program code or modify the AndroidManifest. xml file.
1. modify the program code.
We need to add the corresponding code in the onCreate method of A ctivity. Pay attention to the location of the Code, which must be called before the setContentView () method.
Public class Home extends Activity {@ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); requestWindowFeature (Window. FEATURE_NO_TITLE); // The title bar getWindow () of the program is not displayed (). setFlags (WindowManager. layoutParams. FLAG_FULLSCREEN, WindowManager. layoutParams. FLAG_FULLSCREEN); // The title bar setContentView (R. layout. main );}}
2. Modify AndroidManifest. xml.
You can modify the attribute values of tags or tags. The difference is that all the activities after the tag is modified will be in full screen mode, and the changes will only apply to the current Activity. Note: For android: theme = "@ android: style/Theme. NoTitleBar. Fullscreen", I have set them both. You can make adjustments based on your actual situation.
<? Xml version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: android = "http://schemas.android.com/apk/res/android" package = "org. dw. enotes "android: versionCode =" 1 "android: versionName =" 1.0 "> <application android: icon =" @ drawable/icon "android: label = "@ string/app_name" <! -- Here --> android: theme = "@ android: style/Theme. noTitleBar. fullscreen "> <activity android: name = ". activity. hello "android: label =" @ string/app_name "<! -- Here --> 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> </application> <uses-sdk android: minSdkVersion =" 4 "/> </manifest>
Android gets the width and height of the screen. You only need to call the following code in the Activity:
Int screenWidth; // screen width int screenHeight; // screen height WindowManager windowManager = getWindowManager (); Display display = windowManager. getdefadisplay display (); screenWidth = display. getWidth (); screenHeight = display. getHeight ();