Method One: Configure in Androidmanifest.xml
Assuming you don't want the software to switch between the screens and the screen, the easiest way is to find the activity you specified in the project's androidmanifest.xml with the Android:screenorientation attribute. He has the following number of references:
"Unspecified": The default value is inferred from the system for the display direction. The decision strategy is device-dependent, so different devices will have different display orientations. " Landscape ": Horizontal screen display (width ratio to long)" Portrait ": Vertical display (high width to long)" user ": the current preferred direction for users" behind ": the same direction as the activity below the activity ( "Sensor" in the activity stack: there is a physical sensor to decide. Assume that the user rotates the device and the screen switches between the screens. "Nosensor": ignores physical sensors. This does not change as the user rotates the device (except for the "unspecified" setting).
Method Two: Set in Java code
Set horizontal screen code: setrequestedorientation (Activityinfo.screen_orientation_landscape);//Horizontal screen
Set up the vertical screen code: setrequestedorientation (activityinfo.screen_orientation_portrait);//Vertical screen
Because the horizontal screen has two direction of the horizontal method, and this setting horizontal screen of the statement, assuming that it is not the default horizontal screen direction, will have a horizontal screen rotation of 180 °.
So it is possible to infer whether it is a horizontal screen first. Assuming that it is not rotated again, it will not make the user think the turn is inexplicable! Code such as the following: if (This.getresources (). GetConfiguration (). Orientation ==configuration.orientation_portrait) { Setrequestedorientation (Activityinfo.screen_orientation_landscape);}
How to set up horizontal and vertical screens for Android