Switching between the Android screen and the vertical screen

Source: Internet
Author: User

There are many kinds of switches on Android landscape and vertical screen. But some of the methods introduced are on older versions of Android.

I am now using the situation to write down for memo:

Android version: 4.0-4.4

Requirement: No need to recall OnCreate method when Android screen conversion

Steps:

1, in androidmenifest corresponding activity inside add android:configchanges= "orientation|keyboardhidden| screensize"

2, in the code such as (Roomactivity.java) need a horizontal screen of the place Call method Setrequestedorientation (Activityinfo.screen_orientation_landscape)

3, in the code need vertical screen of the place Setrequestedorientation (activityinfo.screen_orientation_portrait);

Note

1, Setrequestedorientation () is the activity class inside the method

2, ScreenSize (red bold place) This parameter in the Android 4.0 after the version is required, otherwise the screen switch between the time the program will recall the activity inside the OnCreate method.

Switching between the Android screen and the vertical screen

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.