Recently, the development involves dynamically specifying screen orientation, which is summarized as follows:
Activity screen attributes include the following:
Activityinfo. screen_orientation_landscape, // specify the landscape
Activityinfo. screen_orientation_portrait, // specify the portrait Screen
Activityinfo. screen_orientation_user, // user orientation
Activityinfo. screen_orientation_nosensor, // not affected by gravity
Activityinfo. screen_orientation_sensor_landscape, // Dynamic screen Conversion
Activityinfo. screen_orientation_sensor_portrait, // converts the portrait screen dynamically.
Activityinfo. screen_orientation_full_sensor, // orientation based on gravity Transformation
After learning about the activity attributes, you can set them accordingly.
It can be executed in the oncreate () method.
Setrequestedorientation (activityinfo. screen_orientation_full_sensor );
This enables full screen redirection.
Colleagues can also use methods
@ Override
Public void onconfigurationchanged (configuration newconfig ){
// Int type = This. getresources (). getconfiguration (). orientation;
If (newconfig. Orientation = configuration. orientation_landscape ){
// Switch to the landscape
} Else if (newconfig. Orientation = configuration. orientation_portrait ){
// Switched to the portrait Screen
}
Super. onconfigurationchanged (newconfig );
}
Listen to screen changes to respond.