How to set up full screen in Android

Source: Internet
Author: User

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)

  1. Public void OnCreate (Bundle savedinstancestate) {
  2. Super.oncreate (savedinstancestate);
  3. //Set Untitled
  4. Requestwindowfeature (Window.feature_no_title);
  5. //Set fullscreen
  6. GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
  7. WindowManager.LayoutParams.FLAG_FULLSCREEN);
  8. Setcontentview (R.layout.main);
  9. }

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

  1. <?xml version="1.0" encoding="Utf-8"?>
  2. <manifest xmlns:android="Http://schemas.android.com/apk/res/android"
  3. package="Com.andyidea"
  4. android:versioncode="1"
  5. Android:versionname="1.0" >
  6. <USES-SDK android:minsdkversion="8"/>
  7. <application android:icon="@drawable/icon" android:label="@string/app_name" >
  8. <activity android:name=". Login. Loginactivity "
  9. Android:theme="@android: style/android. Notitlebar.fullscreen "
  10. Android:label="@string/app_name" >
  11. <intent-filter>
  12. <action android:name="Android.intent.action.MAIN"/>
  13. <category android:name="Android.intent.category.LAUNCHER"/>
  14. </intent-filter>
  15. </activity>
  16. </application>
  17. </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

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.