How to set up horizontal and vertical screens for Android

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.