Original post address: http://blog.sina.com.cn/s/blog_7dec808c010147f5.html
First: this is also a common method for getting started.
Requestwindowfeature (window. feature_no_title); // remove the title bar.
Note that this sentence must be written before the setcontentview () method, otherwise the second type of error will be reported: defined in the androidmanifest. xml file
<Applicationandroid: icon = "@ drawable/icon" Android: Label = "@ string/app_name" Android: theme = "@ Android: style/theme. notitlebar">
As you can see, the title bar will be removed for the entire application. 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>
Copy code
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">
Copy code
In this way, the title bar can be removed.
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.
Next we will introduce the full screen method: the first method
Getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen );
Second
Android: theme = "@ Android: style/theme. notitlebar. fullscreen"
Third
Application Android: icon = "@ drawable/icon"