Android-screenorientation screen Settings

Source: Internet
Author: User

1.xml, this is mainly in the androidmanifest.xml to find activity, and then set the property inside, as follows

<application android:label= "@string/app_name" android:icon= "@mipmap/ic_launcher_calculator" > <activity an Droid:name= "Calculator"Android:theme= "@style/calculator.theme"Android:windowsoftinputmode= "Statealwayshidden"<!--screen Settings--
Android:screenorientation
= "Portrait"Android:launchmode= "Singletask" > <intent-filter> <action android:name= "Android.intent.action.MAIN"/&G T <category android:name= "Android.intent.category.DEFAULT"/> <category android:name= "android.intent . category. LAUNCHER "/> <category android:name=" Android.intent.category.APP_CALCULATOR "/> </in Tent-filter> </activity> </application>

This property android:screenorientation= "Portrait" has the following properties

"Unspecified": The default value is determined by the system to determine the direction of the display. The decision strategy is related to the device, so different devices will have different display directions.
"Landscape": Horizontal screen display (width ratio to long)
"Portrait": Vertical display (high width to long)
"User": the current preferred direction for users
"Behind": in the same direction as the activity below the activity (in the activity stack)
"Sensor": there is a physical sensor to decide. If the user rotates the device, the screen will switch between the screens.
"Nosensor": ignores the physical sensor so that it does not change as the user rotates the device (except for the "unspecified" setting).

2. Setting in the Code

// Set Horizontal screen setrequestedorientation (activityinfo.screen_orientation_landscape); // setting up a vertical screen setrequestedorientation (activityinfo.screen_orientation_portrait); /* because the horizontal screen has two direction of the horizontal method, and this setting horizontal screen of the statement, if not the default horizontal screen direction, will have a horizontal screen rotation of 180 °. So you can first determine whether it has been horizontal screen, if not rotated, will not let the user feel the turn of the inexplicable! The code is as follows:*/if(this. getresources (). GetConfiguration (). Orientation = =  configuration.orientation_portrait) {setrequestedorientation (activityinfo.screen_orientation_landscape);}

Android-screenorientation screen Settings

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.