Android programming to set Full-screen method instance

Source: Internet
Author: User
Tags filter xmlns

Android programming to set Full-screen method instance

The example in this article describes the way Android programming is set to Full-screen. Share to everyone for your reference, specific as follows:

In real-world application development, we sometimes need to set the activity to a full screen display, in general, there are two ways to set the Full-screen display effect. First, you can set it in code, and second, set the full screen through the manifest configuration file.

First: Set in code (as follows)

Package Xiaohang.zhimeng;

Import android.app.Activity;

Import Android.content.pm.ActivityInfo;

Import Android.os.Bundle;

Import Android.view.Window;

Import Android.view.WindowManager;

public class Activity01 extends activity {

@Override

public void OnCreate (Bundle savedinstancestate) {

Super.oncreate (savedinstancestate);

Set to no title bar

Requestwindowfeature (Window.feature_no_title);

Set to Full-screen mode

GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Set to horizontal screen

Setrequestedorientation (Activityinfo.screen_orientation_landscape);

Setcontentview (R.layout.main);

}

}

But note: Set in the code, set untitled and set the full screen of two pieces of code to be placed in Setcontentview (R.layout.main); In front of this piece of code. Otherwise, it will be an error.

Second: Set up in the manifest configuration file

  

  

Package= "Com.ladygaga.playboy"

Android:versioncode= "1"

Android:versionname= "1.0" >

  

  

  

Android:screenorientation= "Sensor"

Android:label= "@string/app_name" >

  

  

  

  

  

  

  

Or:

  

  

Package= "Com.ladygaga.playboy"

Android:versioncode= "1"

Android:versionname= "1.0" >

  

  

Android:theme= "@android: Style/theme.notitlebar.fullscreen"

Android:label= "@string/app_name" >

  

Android:label= "@string/app_name" >

  

  

  

  

  

  

  

Add attributes to nodes in the corresponding activity: the code is as follows:

Android:theme= "@android: Style/theme.notitlebar.fullscreen"

That is, you can set up an activity to display in full screen. If set to Android:theme= "@android: Style/theme.notitlebar" That is only set to no title state.

I hope this article will help you with the Android program.

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.