How to Set full screen for Android

Source: Internet
Author: User

The blog for Android-idea posted on the internet is http://blog.csdn.net/cjjky/article/details/6337172.

In practical applicationProgramDuring development, we sometimes need to set the activity to full screen display. Generally, we can set the full screen display effect in two ways. FirstCodeCan be set, second, set full screen through the manifest configuration file.

1. Set it in the Code (as follows)

Public VoidOncreate (bundle savedinstancestate ){Super. Oncreate (savedinstancestate );//Set no titleRequestwindowfeature (window. feature_no_title );//Set full screenGetwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); setcontentview (R. layout. Main );}

However, you must note that if you set it in the Code, the two sections of code with no title and full screen should be placed in front of setcontentview (R. layout. Main. Otherwise, an error is reported.

 

Second, set it 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 the property Android: theme = "@ Android: style/theme. notitlebar. fullscreen" to the corresponding activity node to set the full screen display of an activity. If it is set to Android: theme = "@ Android: style/theme. notitlebar", it is only set to the Untitled state.

 

Note: I added this attribute to my project according to the second method, but the compiler will prompt: Error: no resource found that matches the given name (at 'Theme 'with value' @ android. style/android. notitlebar. fullscreen '). in this case, you need to clear the project and everything will be OK.

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.