Android Remove Title method

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: Setcontentview before code oncreate (below)
View plaincopy to Clipboardprint?
   public void OnCreate (Bundle savedinstancestate) {
                      super.oncreate (savedinstancestate);
                     //title
        &NB Sp             requestwindowfeature (window.feature_no_title);
                     //cancel status bar
        &NB Sp           GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
                    Setcontentview (R.layout.main);
     }

However, it is important to note that in the code settings, set untitled and set the full screen of the two code to be placed in the Setcontentview (r.layout.main) (interface rendering, complete the full screen is not possible) before the code. Otherwise you will get an error.

Second: Set in the manifest configuration file

The first of these methods
① Create a Theme.xml file in the Res/values directory (used to put styles)

<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<!--names is the name of the style, and parent inherits that parent style--
<style name= "Theme_fullscreen" parent= "Android:Theme.Black" >
<item name= "Android:windownotitle" >true</item> <!--set Untitled-
<item name= "Android:windowfullscreen" >?android:windowNoTitle</item>

<!--are you populating the slow screen, referencing the value of Android:windownotitle? android:windownotitle, depending on the value of Android:windownotitle--
</style>
</resources>

②<activity android:name= ". Login. Loginactivity "Android:theme=" @style/theme_fullscreen "/>

Second method

<?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/theme.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>

Third: This is not commonly used in general applications, which is to create a new Style.xml file under the Res/values directory for example:
<?xml version= "1.0" encoding= "UTF-8"?>
<resources>
<style name= "Theme_notitle" >
<item name= "Android:windownotitle" >true</item>
</style>
</resources>


In this way, we customize a style, which is the equivalent of a topic, and then define it in the Androidmanifest.xml file.

<application android:icon= "@drawable/icon"
Android:label= "@string/app_name"
Android:theme= "@style/theme_notitle" >
This can also be achieved by removing the title bar effect

Android Remove Title method

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.