Two full-screen display modes on the android Interface

Source: Internet
Author: User

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

1. Set in Java code

Super. oncreate (savedinstancestate); requestwindowfeature (window. feature_no_title); // No titlegetwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); // setcontentview (R. layout. main );

Note that the two Java codes must be placed before setcontentview (); otherwise, an error is reported. The error is shown as follows.

[Plain]View
Plaincopy

  1. 01-14 05:25:41. 429: E/androidruntime (7405): caused by: Android. util. androidruntimeexception: requestfeature () must be called before adding content

2. modify it in the manifest File

Add Android: theme = "@ Android: style/theme. notitlebar. fullscreen" to the default activity.

[HTML]View
Plaincopy

  1. <Activity Android: Name = ". mainactivity"
  2. Android: Label = "@ string/app_name"
  3. Android: theme = "@ Android: style/theme. notitlebar. fullscreen"
  4. >
  5. <Intent-filter>
  6. <Action Android: Name = "android. Intent. Action. Main"/>
  7. <Category Android: Name = "android. Intent. Category. launcher"/>
  8. </Intent-filter>
  9. </Activity>

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.