How to remove the title bar (using the request window feature)( Window.FEATURE_ NO_ Title); why it fails)

The method to remove the title bar (use requestWindowFeature(window.feature_no_title); Why does it fail?
Use RequestWindowFeature (window.feature_no_title) to hide the cause of the failure of the title bar, possibly because the activity inherits from AppCompatActivity. The use method is described in detail below:
A, if you create the activity inherited activity:
the first one: introduction to often use a method:

requestWindowFeature(Window.FEATURE_NO_TITLE);

//remove the title bar of note that this sentence must be written in the book of the setContentView () method, in front of or complains
the second: in the AndroidManifest. Defined in the XML file

<application android:theme="@android:style/Theme.NoTitleBar">

Wrote, then the application will remove the title bar, if just want to get rid of a certain Activity of the title bar, you can add this property to the Activity inside the tag
the third: this is not commonly used in general application, is in the res/values below to create a new style. The XML file
code is as follows:
duplicate code

<?xml version="1.0" encoding="UTF-8" ?>
<resources>
    <style name="notitle">
        <item name="android:windowNoTitle">
            true
        </item>
    </style>
</resources>

Copying code
in this way, we can customize a style, is equivalent to a topic, and then in the AndroidManifest. Defined in the XML file, also can achieve the effect of removing the title bar
code is as follows:

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

AppCompatActivity>

getSupportActionBar().hide();
//Remove the title bar Note that this sentence must be written after the setContentView() method

Second: You can do the following in AndroidManifest.xml, so there is no title bar

<application
   android:theme="@style/Theme.AppCompat.NoActionBar">


Read More: