Remove the title bar from the android Screen

Source: Internet
Author: User

 

There are three methods to remove the title bar from the screen:

 

1. Java code implementation

@ Override

Public void onCreate (Bundle savedInstanceState ){

Super. onCreate (savedInstanceState );

 

RequestWindowFeature (Window. FEATURE_NO_TITLE );

 

SetContentView (R. layout. main );

//...

}

Pay attention to the position of this statement. It seems that all requestWindowFeature operations should be placed before setContentView.

 

However, if this method is used, the user experience is poor. When the Activity is to be displayed, the title bar will still appear and be removed.

 

2. Custom style configuration file

Add style. xml in \ res \ values:

<? 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 clear!

Then, in the AndroidManifest. xml file, add android: theme = "@ style/NoTitle to the node of the activity that needs to remove the title bar. The Code is as follows:

<Activity android: name = ". MainActivity"

Android: configChanges = "orientation | keyboardHidden"

Android: theme = "@ style/NoTitle"/>

 

3. directly modify AndroidManifest. xml

We can directly call the system without the need 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, set the application:

<Application android: icon = "@ drawable/lightbulb" android: label = "@ string/app_name"

Android: theme = "@ android: style/Theme. NoTitleBar">

 

Title bar can also be customized. Please refer to the article "Custom Activity Title bar (title bar)"

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.