1. Java Code Implementation
@Override Public void onCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Requestwindowfeature (window.feature_no_title); Setcontentview (R.layout.main); // ...}
Note Where the statement is located, it seems that all requestwindowfeature operations are placed in front of the Setcontentview.
However, using this method, the user experience is not very good, and when the activity is about to be displayed, the title bar will still appear and then removed.
2. Customizing the style configuration file
In the \res\values inside the Style.xml add:
<?xml version="1.0" encoding="utf-8"? ><resources > <style name="notitle" parent="android:theme" > <item name="android:windownotitle">true</ Item> </style></resources>
The code here should be read clearly!
Then in the Androidmanifest.xml file, add android:theme= "@style/notitle to the node that needs to remove the activity from the title bar as follows:
<activity android:name=". Mainactivity" android:configchanges="orientation|keyboardhidden " android:theme="@style/notitle" />
3. Make changes directly in the Androidmanifest.xml
It turns out that we can simply call the system without having to customize the style configuration:
<activity android:name=". Mainactivity" android:configchanges="orientation|keyboardhidden " android:theme="@android: Style/theme.notitlebar" />
If we want to set the entire application to remove the title bar, then set the application:
<application android:icon="@drawable/lightbulb" android:label="@ String/app_name" android:theme="@android: Style/theme.notitlebar ">
Android 3 ways to remove title bar