Android Set Horizontal screen, disable screen rotation, activity reset [Update Video player related]

Source: Internet
Author: User

1. Setting the screen orientation

When the orientation of the screen is specified (not screen_orientation_unspecified), the screen does not rotate itself actively

There are 2 ways to control the screen orientation:

1.1 Change androidmanifest.xml

added to the activity of Androidmanifest.xml:Horizontal screen:
           android:screenorientation= "Landscape" vertical screen:           android:screenorientation= "Portrait"

1.2 setrequestedorientation

Horizontal screen:

Setrequestedorientation (Activityinfo.screen_orientation_landscape);

Vertical screen:

Setrequestedorientation (activityinfo.screen_orientation_portrait);


Activityinfo:

int

screen_orientation_behind

constant  corresponding to  behind  in the  screenorientation  attribute.

int

screen_orientation_full_sensor

constant  corresponding to  fullsensor  IN THE  screenorientation  attribute.

int

screen_orientation_full_user

constant  corresponding to  fulluser  in the  screenorientation  attribute.

int

screen_orientation_landscape

constant  corresponding to  landscape  in the  screenorientation  attribute.

int

screen_orientation_locked

constant  corresponding to  locked  in the  screenorientation  attribute.

int

screen_orientation_nosensor

constant  corresponding to  nosensor  in the  screenorientation  attribute.

int

screen_orientation_portrait

constant  corresponding to  portrait  in the  screenorientation  attribute.

int

screen_orientation_reverse_ LANDSCAPE

constant corresponding to  reverselandscape  IN THE  screenorientation   attribute.

int

screen_orientation_reverse_ PORTRAIT

constant corresponding to  reverseportrait  IN THE  screenorientation   attribute.

int

screen_orientation_sensor

constant  corresponding to  sensor  in the  screenorientation  attribute.

int

screen_orientation_sensor_ LANDSCAPE

constant corresponding to  sensorlandscape  IN THE  screenorientation   attribute.

int

screen_orientation_sensor_ PORTRAIT

constant corresponding to  sensorportrait  IN THE  screenorientation   attribute.

int

screen_orientation_unspecified

constant  corresponding to  unspecified  IN THE  screenorientation  attribute.

int

screen_orientation_user

constant  corresponding to  user  in  the  screenorientation  attribute.

int

screen_orientation_user_ LANDSCAPE

constant corresponding to  userlandscape  IN THE  screenorientation   attribute.

Int

Screen_orientation_user_portrait

Constant corresponding to userportrait in the screenorientation attribute.




2. Disable screen rotation and reset activity

The activity.oncreate method is forced to be called after the screen is rotated, so the Activity is reset

Forbidden Method:

Change androidmanifest.xml

android:configchanges= "Orientation"


recent Android player. After encountering the above method, the screen rotation still occurs after the trigger activity.oncreate, screensize handling

The detailed code is:

Android:configchanges= "Orientation|keyboardhidden|screensize"


Disable reset activity will cause screen to be turned upside-down and need to be manually corrected.





Android Set Horizontal screen, disable screen rotation, activity reset [Update Video player related]

Related Article

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.