ScreenOrientation and screenorientation
<Activity android: name = ". MyActivity"
Android: label = "@ string/app_name"
Android: screenOrientation = "portrait">
Android: screenOrientation: sets the direction of the activity. The value can be any of the following strings:
"Unspecified"
-Default value: select the display direction from the system. The display direction may vary with devices.
"Landscape"
-Forward Direction
"Portrait"
-Portrait
"User"
-Use the current preferred direction of the cursor
"Behind"
-Same direction as the activity under the activity Stack
"Sensor"
-The direction is determined based on the physical direction sensor. It depends on the direction in which the camera is used. When the camera is used to rotate the device, it changes with the camera.
"Nosensor"
-The direction is determined without the physical direction sensor. the sensor is ignored. Therefore, when the device is rotated using the secondary node, the display will not change with the secondary node. except for this difference, the system chooses to use the same policy orientation for "unspecified" settings. the system selects the same display direction based on "unspecified" ("unspecified.
Its implementation in code: for example
SetRequestedOrientation (ActivityInfo. SCREEN_ORIENTATION_LANDSCAPE); // force the screen to be landscape
SetRequestedOrientation (ActivityInfo. SCREEN_ORIENTATION_PORTRAIT); // force the portrait Screen
After switching between the horizontal and vertical screens, the Activity will re-execute the onCreat function, but in the Mainfest. after android: screenOrientation = "user" android: configChanges = "orientation | keyboardHidden" is added to xml, the OnCreat function will not be executed after horizontal and vertical screen switching, instead, we will call onConfigurationChanged (), so that we can control the switching between the landscape and landscape screens.
Or create the layout-land and layout-port directories under the res directory, and the corresponding layout files remain unchanged. Layout-land is the layout of the horizontal screen, and layout-port is the layout of the vertical screen.