Three methods for removing the title bar and full screen for Android

Source: Internet
Author: User

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:

  1. <? XML version = "1.0" encoding = "UTF-8"?>

  2. <Resources>

  3. <Style name = "notitle">

  4. <Item name = "Android: windownotitle"> true </item>

  5. </Style>

  6. </Resources>

Copy code

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

  1. <Application Android: icon = "@ drawable/icon"

  2. Android: Label = "@ string/app_name"
  3. 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"

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.