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.