In AndroidProgramThe interface is always in one direction and does not change with the phone direction: you only need to configure it in androidmanifest. xml.
Add the Android: screenorientation = "Landscape" attribute to the androidmanifest. XML activity (activity that requires no redirection) configuration (landscape is horizontal and portrait is vertical ). For example:
<? XML version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: Android = "http://schemas.android.com/apk/res/android" package = "com. ray. linkit "Android: versioncode =" 1 "Android: versionname =" 1.0 "> <application Android: icon =" @ drawable/icon "Android: label = "@ string/app_name"> <activity Android: Name = ". main "Android: Label =" @ string/app_name "Android: screenorientation =" portrait "> <intent-filter> <action Android: Name =" android. intent. action. main "/> <category Android: Name =" android. intent. category. launcher "/> </intent-filter> </activity> <activity Android: Name = ". gameplay "Android: screenorientation =" portrait "> </activity> <activity Android: Name = ". optionview "Android: screenorientation =" portrait "> </activity> </Application> <uses-SDK Android: minsdkversion =" 3 "/> </manifest>
In addition, the activity is restarted every time the screen direction is switched in Android. Therefore, you should save the status of the current activity before the activity is destroyed and load the configuration when the activity is created again, in progress, the game will not automatically restart!
To avoid restarting the activity during screen conversion, you can use the function in androidmanifest. in the XML file, redefine the direction (add the Android: configchanges = "keyboardhidden | orientation" attribute to each activity), and control it based on the onconfigurationchanged (configuration newconfig) method of the activity, in this way, the activity will not be restarted during screen conversion, but the onconfigurationchanged (configuration newconfig) Hook method will be called. For example:
If (newconfig. Orientation = configuration. orientation_landscape) {// transverse setcontentview (R. layout. file_list_landscape);} else {// vertical setcontentview (R. layout. file_list );}
In the simulator, you can use the shortcut key F12 or Ctrl + F11 to switch the program to the screen. Of course, you can use the receivemulator.exe-skin HVGA-L directly to start the horizontal screen program when using the command line to start the simulator.