Full Screen in Android and remove the title bar, android title bar

Source: Internet
Author: User

Full Screen in Android and remove the title bar, android title bar
Full Screen in Android and remove the title bar

How to remove the title bar
First: a method that is frequently used when 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.


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>

In this way, we have customized a style, which is equivalent to a topic and defined in the AndroidManifest. xml file. This can also remove the title bar.


<application android:icon="@drawable/icon" 
android:label="@string/app_name"
android:theme="@style/notitle">



Summary of three methods for removing the title bar

First, sometimes we will see that the title bar appears first and then disappears, because we only define

The second one is better than the first one, so this will not happen.

Third, I personally think it is best to separate functions to facilitate maintenance and expansion.


Introduction to 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"

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.