Activity Full Screen Settings
Method 1:Androidmanifest. xml
<Activity Android: Name = "myacitivty" Android: theme = "@ Android: style/theme. notitlebar. fullscreen"/>
Method 2:Code Implementation
Requestwindowfeature (window. feature_no_title); // hide the title bar
Getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); // hide the status bar
Note:The full screen code must be set before setcontentview (R. layout. Main). Otherwise, an error is returned.
Method 3: code implementation (not before setvontentview)
Full Screen: getwindow (). addflags (windowmanager. layoutparams. flag_fullscreen );
Non-full screen: getwindow (). clearflags (windowmanager. layoutparams. flag_fullscreen );
Activity horizontal and vertical Screen Settings
Method 1:Androidmanifest. xml
<Activity Android: Name = "myacitivty" Android: screenorientation = "Landscape"/> // or "portrait"
Method 2:Code Implementation
Setrequestedorientation (activityinfo. screen_orientation_landscape );
// Activityinfo. screen_orientation_landscape (landscape)
// Activityinfo. screen_orientation_portrait (portrait screen)
Obtain the horizontal screen direction
Int orientation = This. getresources (). getconfiguration (). orientation;
Activity screen always displays
Method1: androidmanifest. xml add permissions
<Uses-Permission Android: Name = "android. Permission. wake_lock"/>
Method 2: code implementation
Getwindow (). addflags (windowmanager. layoutparams. flag_keep_screen_on );