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)"