Android Programming Set Full Screen Method Example detailed _android

Source: Internet
Author: User

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

<?xml version= "1.0" encoding= "Utf-8"?> <manifest xmlns:android=
"http://schemas.android.com/apk/res/" Android "
   package=" Com.ladygaga.playboy "
   android:versioncode=" 1 "
   android:versionname=" 1.0 ">
  <USES-SDK android:minsdkversion= "8"/>
  <application android:icon= "@drawable/icon" @ String/app_name ">
    <activity android:name=" Com.ladygaga.test.ImageSwitcherTest "
         android: Screenorientation= "sensor"
         android:label= "@string/app_name" >
      <intent-filter>
        <action Android:name= "Android.intent.action.MAIN"/>
        <category android:name= "Android.intent.category.LAUNCHER" "/>
      </intent-filter>
    </activity>
  </application>
</manifest>

Or:

<?xml version= "1.0" encoding= "Utf-8"?> <manifest xmlns:android=
"http://schemas.android.com/apk/res/" Android "
   package=" Com.ladygaga.playboy "
   android:versioncode=" 1 "
   android:versionname=" 1.0 ">
  <USES-SDK android:minsdkversion= "8"/>
  <application android:icon= "@drawable/icon"
    android:theme= "@android: Style/theme.notitlebar.fullscreen"
    android:label= "@string/app_name" >
    <activity android: Name= "Com.ladygaga.test.ImageSwitcherTest"
         android:label= "@string/app_name" >
      <intent-filter >
        <action android:name= "Android.intent.action.MAIN"/>
        <category android:name= " Android.intent.category.LAUNCHER "/>
      </intent-filter>
    </activity>
  </ Application>
</manifest>

Add attributes to nodes in the corresponding activity:

Copy Code code 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.

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.