in the XML file, set:
To achieve this, simply declare the activity in Androidmanifest.xml with an attribute: Android:screenorientation, the property value landscape fixed horizontal screen, The portrait is a fixed vertical screen.
<!--android:screenorientation= "portrait" vertical Screen android:screenorientation= "landscape" horizontal screen android:screenorientation= "Unspecified" does not indicate direction --<activity android:label= "@string/app_name" android:name= ". Lockthescreenactivity " android:screenorientation=" Portrait "
b) The code is implemented as follows:
@Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setrequestedorientation (Activityinfo.screen_orientation_landscape);//cross-screen//setrequestedorientation ( activityinfo.screen_orientation_portrait) Vertical screen Setcontentview (r.layout.main); }
When the screen is automatically switched, the default state of the application will recall OnCreate, which is equivalent to restarting the application once. At the same time, layout may cause a problem that cannot be properly adapted by horizontal screen. In order to solve The program restart problem caused by Rotary screen and keyboard switching, an additional attribute is required: android:configchanges. This property can be understood as a listener that will intercept the spin screen and keyboard switching events, preventing the program from restarting and becoming the callback Onconfigurationchanged method. The properties commonly used here are : keyboardhidden|orientation.
Go to the title
<span style= "FONT-SIZE:14PX;" >public void OnCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); This.requestwindowfeature (Window.feature_no_title); } </span>
Full Screen
<span style= "FONT-SIZE:14PX;" >public void OnCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); This.getwindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_ fullscreen); } </span>
android--Lock horizontal screen, vertical screen, go to title full screen