Android developed three ways to get rid of the title bar and recommend a third

Source: Internet
Author: User

Android: Three ways to get rid of title bar and three ways to fullscreen


The first type: A method commonly used when getting started
Add the following code to the OnCreate function:
Requestwindowfeature (window.feature_no_title);//Remove the title bar
Note This sentence must be written in front of the Setcontentview () method, or it will be an error


Another type: defined in the Androidmanifest.xml file
<application android:icon= "@drawable/icon" android:label= "@string/app_name" Android:theme= "@android: style/ Theme.notitlebar ">
Can be seen, the whole application will be removed from the title bar, assuming that only want to remove an activity of the title bar, you can add this attribute to the activity tag.




Third: This is not used in general applications, that is, in the Res/values folder to create a new Style.xml file such as:


<?xml version= "1.0" encoding= "UTF-8"?>


<resources>


<style name= "Notitle" >


<item name= "Android:windownotitle" >true</item>


</style>


</resources>


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


<application android:icon= "@drawable/icon"


Android:label= "@string/app_name"


Android:theme= "@style/notitle" >




Three a summary of the method of removing the title bar first, sometimes we will see that the title bar will appear first, and then disappear, because we are only in the activity of the OnCreate method defined, the other is relatively the first kind of better, will not appear, the third I personally feel the best, This separates the functions and facilitates maintenance and expansion.

Android developed three ways to get rid of the title bar and recommend a third

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.