Full Screen horizontal/vertical screen for Android Activity

Source: Internet
Author: User

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 );

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.