Two ways to achieve full-screen display in the Android interface

Source: Internet
Author: User

In the development of Android applications, we will encounter some of the interface set to full-screen display format, there are two ways to implement. One is implemented in Java code, and the other is implemented in a configuration file.

1. Set in Java code

Super . OnCreate (savedinstancestate);  Requestwindowfeature (window.feature_no_title);   // No title   GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,                WindowManager.LayoutParams.FLAG_ fullscreen);   // Full  screen Setcontentview (R.layout.main);  

It is important to note that both Java code must be placed in Setcontentview (); Before, otherwise it will error, the errors shown below.

2. Modify in the manifest file

Add Android:theme= "@android: Style/theme.notitlebar.fullscreen" to the default startup activity

<ActivityAndroid:name=". Mainactivity "Android:label= "@string/app_name"Android:theme= "@android: Style/theme.notitlebar.fullscreen"            >      <Intent-filter>          <ActionAndroid:name= "Android.intent.action.MAIN" />          <categoryAndroid:name= "Android.intent.category.LAUNCHER" />      </Intent-filter>  </Activity>

Two ways to achieve full-screen display in the Android interface

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.