Get rid of the title bar on Android screen

Source: Internet
Author: User

In Android development, each activity will default with a title bar to display the program name, sometimes in order to enlarge the screen display area need to remove the title bar, remove the title bar on the screen has 3 methods,

The first method is to remove the title bar from the code

Add the following code to the activity's OnCreate:

Java code
    1. This.requestwindowfeature (Window.feature_no_title);

But with this approach, the title bar will still appear when the activity is about to be displayed, and then removed, and the user experience is not good.

The second method is to use the style configuration file , as follows:

1. Create an XML file under the Res/values folder named Mainstyle.xml, which reads as follows:

Java code
    1. <?xml version="1.0" encoding="Utf-8"?>
    2. <resources>
    3. <style name="Notitle" parent="Android:theme" >
    4. <item name="Android:windownotitle" >true</item>
    5. </style>
    6. </resources>

2. Then add a style attribute to the activities node in Androidmanifest.xml that needs to remove the title bar, with the following code:

Java code
    1. <activity android:name=". View. Autotaskdemo "android:label=" @string/app_name "
    2. android:configchanges= "keyboardhidden|orientation|locale" android:theme="@style/notitle" >

The third method is to modify directly in the Androidmanifest.xml,

Add a style attribute to the activities node that needs to remove the title bar, and the code is as follows:

Java code
    1. <activity android:name=". View. Settingactivity "
    2. android:configchanges= "keyboardhidden|orientation" Android:theme="@android: Style/theme.notitlebar"/>

can also be modified on the application node of the Androidmanifest.xml file, valid for all activity, the code is as follows:

Java code
    1. <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme= "@ Android:style/theme.notitlebar ">

Get rid of the title bar on Android screen

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.