In the actual application development, we sometimes need to set the Activity to display the full screen, in general, there are two ways to set the screen display effect. One is to set the full screen through the manifest configuration file by setting it in code.
One: Set in code (below)
- Public void OnCreate (Bundle savedinstancestate) {
- Super.oncreate (savedinstancestate);
- //Set Untitled
- Requestwindowfeature (Window.feature_no_title);
- //Set fullscreen
- GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- Setcontentview (R.layout.main);
- }
However, it is important to note that in the code, set the untitled and set the full screen of the two-segment code to be placed in the Setcontentview (R.layout.main); In front of this piece of code. Otherwise you will get an error.
Second: Set in the manifest configuration file
- <?xml version="1.0" encoding="Utf-8"?>
- <manifest xmlns:android="Http://schemas.android.com/apk/res/android"
- package="Com.andyidea"
- android:versioncode="1"
- Android:versionname="1.0" >
- <USES-SDK android:minsdkversion="8"/>
- <application android:icon="@drawable/icon" android:label="@string/app_name" >
- <activity android:name=". Login. Loginactivity "
- Android:theme="@android: style/android. 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>
- </manifest>
Add a property to the node in the corresponding activity: android:theme= "@android: Style/theme.notitlebar.fullscreen" To set an activity full-screen display. If set to Android:theme= "@android: Style/theme.notitlebar" is just set to untitled state.
How to set up full screen in Android