Android development removes the title bar. The third method is recommended.

Source: Internet
Author: User

Android development removes the title bar. The third method is recommended.
Android: three methods to remove the title bar and full screen


First: a method that is often used when getting started
Add the following code to the onCreate function:
RequestWindowFeature (Window. FEATURE_NO_TITLE); // remove the title bar.
Note that this sentence must be written before the setContentView () method. Otherwise, an error will be reported.


Type 2: defined in the AndroidManifest. xml file
<Application android: icon = "@ drawable/icon" android: label = "@ string/app_name" android: theme = "@ android: style/Theme. NoTitleBar">
As you can see, the entire application will remove the title bar. If you only want to remove the title bar of an Activity, you can add this attribute to the activity tag.




Third: This is not commonly used in general applications. It is to create a style. xml file under the res/values directory, for example:


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


<Resources>


<Style name = "notitle">


<Item name = "android: windowNoTitle"> true </item>


</Style>


</Resources>


In this way, we customize a style, which is equivalent to a topic and then defined in the AndroidManifest. xml file.


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


Android: label = "@ string/app_name"


Android: theme = "@ style/notitle">




Three methods to remove the title bar are summarized first. Sometimes we can see that the title bar appears first and then disappears, because we only define it in the oncreate method of activity, the second one is better than the first one, so it won't happen. The third one I personally feel the best. In this way, the functions are separated to facilitate maintenance and expansion.
How to remove title bar title from Android Development

It is actually very simple to remove the title bar from Android development. There are two methods: adding a title in the Code and adding a title in AndroidManifest. add in xml: 1. Implement in code: setContentView (R. layout. main) added before: requestWindowFeature (Window. FEATURE_NO_TITLE); the title bar is gone. 2. Implement in AndroidManifest. xml: Add the following configuration when registering an Activity. <Activity android: name = ". Activity"

How does Android cancel the default title bar content?

It is actually very simple to remove the title bar from Android development. There are two methods: add the title in the code, and add the title in AndroidManifest. xml:
1. Implementation in code:
Before setContentView (R. layout. main) in this method, add:
RequestWindowFeature (Window. FEATURE_NO_TITLE); the title bar is gone.
2. Implementation in AndroidManifest. xml:
You can add the following configuration when registering an Activity.
<Activity android: name = ". Activity"
Android: theme = "@ android: style/Theme. NoTitleBar">
</Activity>

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.