Cancel the title bar in full screen mode in Android, and set notitlebar in tabhost.

Source: Internet
Author: User

Cancel the title bar in full screen mode in Android, and set notitlebar in tabhost.

The default title bar of Android is relatively difficult to control. You need to remove the custom title bar.
Remove the title bar:
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, 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 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.

Note: This method does not work on the tabhost on the Samsung i9300 mobile phone of android4.1.1. You need to add settheme to the first method for control.
Settheme (Android. R. style. theme_black_notitlebar );
Requestwindowfeature (window. feature_no_title );
Setcontentview (R. layout. api_tab_host );

Third: Custom styles, which are not commonly used in general applications. 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>
It 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">
Removed the title bar.

First, we can see that the title bar appears first and then disappears, because it is defined in the oncreate method of activity.
The second one is better than the first one, so this will not happen.
The third method can separate functions to facilitate maintenance and expansion, but it is troublesome.

------------------------------------------------------
Full Screen:
First
Getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen );

Second
Android: theme = "@ Android: style/theme. notitlebar. fullscreen"

third
application Android: icon = "@ drawable/icon"
Android: Label = "@ string/app_name"
Android: theme = "@ style/fullscreem"

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.