The activity will re-execute the Oncreat function after the screen switch, but add the android:screenorientation= "user" Android to the Android project Mainfest.xml: After configchanges= "Orientation|keyboardhidden", after the screen switch will not go to execute the Oncreat function, but will call Onconfigurationchanged (), So we can control the switching of the screen.
or in the Res directory to establish the Layout-land and Layout-port directory, the corresponding layout file is unchanged. Layout-land is the horizontal screen of the layout,layout-port is the vertical screen layout.
In the <activity/> tab of the Androidmanifest.xml. There is a property to set the activity's support for switching between the portrait and the screen:
<activity android:name= android:screenorientation= " ;
android:screenorientation property values are as follows:
" Unspecified "
-default value. The display direction is selected by the system. Different devices may vary.
Landscape
-Horizontal
"Portrait"
-Portrait
" user "
-user's current preferred orientation
"behind"
-the same direction as the activity under the active stack
sensor
-determines the orientation based on the physical direction sensor. Depending on the direction the user is holding, when the user rotates the device, it changes.
" nosensor "
-the direction is not determined by the physical direction sensor. The sensor is ignored, so when the user rotates the device, the display does not change. In addition to this distinction, the system chooses to use the same policy orientation for the "unspecified" setting. The system selects the same display direction according to the "Unspecified" ("unspecified") setting.
can also be used setrequestedorientation () in the background to make a portrait and the screen toggle
Reference:
/http www.cnblogs.com/bluestorm/archive/2012/05/07/2486954.html
http://blog.csdn.net/nmgchfzhzhg/article/ details/8077133