How to remove the title bar from an Android app

Source: Internet
Author: User

Now I firmly believe that writing a technical blog is of great help to myself. writing a blog gives me a chance to learn and think.

There are three methods to remove the title bar in Android, which also have their own characteristics.

1. Implement in code

This. requestwindowfeature (window. feature_no_title); // remove the title bar.

Remember: This code should be written before setcontentview.

2. Implement in the configuration file (manifest. XML)

<application android:icon="@drawable/icon"         android:label="@string/app_name"         android:theme="@android:style/Theme.NoTitleBar">

In this way, you can set the entire application to a non-title bar. If you only need to set a non-title bar in an activity, you only need to write the third line of code to an activity.

3. Define in the style. xml file

<?xml version="1.0" encoding="UTF-8" ?><resources>    <style name="notitle">        <item name="android:windowNoTitle">true</item>    </style> </resources>

Then you can reference the manifest. xml file. This method is a little more troublesome.

<application android:icon="@drawable/icon"         android:label="@string/app_name"         android:theme="@style/notitle">

In fact, we can see that the second method and the third method are essentially the same, but the second method calls the style defined by the system. XML file, while the third method is to define the style in your own application. XML, and then call it by yourself. In fact, the truth is the same. The third method is more fulfilling.

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.