Android 3 ways to remove title bar

Source: Internet
Author: User

1. Java Code Implementation

@Override  Public void onCreate (Bundle savedinstancestate) {        super.oncreate (savedinstancestate);        Requestwindowfeature (window.feature_no_title);         Setcontentview (R.layout.main);         // ...}

Note Where the statement is located, it seems that all requestwindowfeature operations are placed in front of the Setcontentview.
However, using this method, the user experience is not very good, and when the activity is about to be displayed, the title bar will still appear and then removed.

2. Customizing the style configuration file
In the \res\values inside the Style.xml add:

<?xml version="1.0" encoding="utf-8"? ><resources >        <style name="notitle" parent="android:theme" >                <item name="android:windownotitle">true</ Item>        </style></resources>

The code here should be read clearly!
Then in the Androidmanifest.xml file, add android:theme= "@style/notitle to the node that needs to remove the activity from the title bar as follows:

<activity android:name=". Mainactivity"                    android:configchanges="orientation|keyboardhidden "                     android:theme="@style/notitle" />

3. Make changes directly in the Androidmanifest.xml
It turns out that we can simply call the system without having to customize the style configuration:

<activity android:name=". Mainactivity"                    android:configchanges="orientation|keyboardhidden "                     android:theme="@android: Style/theme.notitlebar" />

If we want to set the entire application to remove the title bar, then set the application:

<application android:icon="@drawable/lightbulb" android:label="@ String/app_name"                    android:theme="@android: Style/theme.notitlebar ">

Android 3 ways to remove title bar

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.