Two Methods for setting full screen or untitled android

Source: Internet
Author: User

During development, we often need to set our applications to full screen or do not want title,

Here there are two methods, one is to set in the Code, the other is to change in the configuration file:

1. Set in the Code:

Package Jason. tutor; import android. app. activity; import android. OS. bundle; import android. view. window; import android. view. windowmanager; public class opengl_lesson1 extends activity {public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // No title requestwindowfeature (window. feature_no_title); // full screen getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); setcontentview (R. layout. main );}}

It should be emphasized that the two sections of code for full screen setting must be in setcontentview (R. layout. main) before, otherwise an error will be reported, and this method has a drawback, that is, when this activity is set to full screen, the title will flash and disappear, that is, the Code is fully valid only when the full screen setting is executed. to avoid this problem, the second method is recommended as follows:

2. modify it in the configuration file (Android: theme = "@ Android: style/theme. notitlebar. fullscreen "):

<?xml version="1.0" encoding="utf-8"?>  <manifest xmlns:android="http://schemas.android.com/apk/res/android"        package="jason.tutor"        android:versionCode="1"        android:versionName="1.0">      <application android:icon="@drawable/icon" android:label="@string/app_name">          <activity android:name=".OpenGl_Lesson1"                    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"                    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>      <uses-sdk android:minSdkVersion="7" />  </manifest>   

If you only want a single activity to be full-screen, the code is just right. If you want all the activities of the entire application to be full-screen, the following code is used:

<?xml version="1.0" encoding="utf-8"?>  <manifest xmlns:android="http://schemas.android.com/apk/res/android"        package="jason.tutor"        android:versionCode="1"        android:versionName="1.0">      <application android:icon="@drawable/icon"                  android:label="@string/app_name"                 android:theme="@android:style/Theme.NoTitleBar.Fullscreen">         <activity android:name=".OpenGl_Lesson1"                    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>      <uses-sdk android:minSdkVersion="7" />  </manifest>   

It should be clear. That's all.


 

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.