Android programming to set Full-screen method instance
The example in this article describes the way Android programming is set to Full-screen. Share to everyone for your reference, specific as follows:
In real-world application development, we sometimes need to set the activity to a full screen display, in general, there are two ways to set the Full-screen display effect. First, you can set it in code, and second, set the full screen through the manifest configuration file.
First: Set in code (as follows)
Package Xiaohang.zhimeng;
Import android.app.Activity;
Import Android.content.pm.ActivityInfo;
Import Android.os.Bundle;
Import Android.view.Window;
Import Android.view.WindowManager;
public class Activity01 extends activity {
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Set to no title bar
Requestwindowfeature (Window.feature_no_title);
Set to Full-screen mode
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Set to horizontal screen
Setrequestedorientation (Activityinfo.screen_orientation_landscape);
Setcontentview (R.layout.main);
}
}
But note: Set in the code, set untitled and set the full screen of two pieces of code to be placed in Setcontentview (R.layout.main); In front of this piece of code. Otherwise, it will be an error.
Second: Set up in the manifest configuration file
Package= "Com.ladygaga.playboy"
Android:versioncode= "1"
Android:versionname= "1.0" >
Android:screenorientation= "Sensor"
Android:label= "@string/app_name" >
Or:
Package= "Com.ladygaga.playboy"
Android:versioncode= "1"
Android:versionname= "1.0" >
Android:theme= "@android: Style/theme.notitlebar.fullscreen"
Android:label= "@string/app_name" >
Android:label= "@string/app_name" >
Add attributes to nodes in the corresponding activity: the code is as follows:
Android:theme= "@android: Style/theme.notitlebar.fullscreen"
That is, you can set up an activity to display in full screen. If set to Android:theme= "@android: Style/theme.notitlebar" That is only set to no title state.
I hope this article will help you with the Android program.