1. Realize that all activity in the application is full screen
Join directly in the manifest
Copy Code code as follows:
Android:theme= "@android: Style/theme.notitlebar.fullscreen"
2. Achieve a single activity full screen
Copy Code code as follows:
Requestwindowfeature (Window.feature_no_title);
GetWindow (). SetFlags (WindowManager.LayoutParams.TYPE_STATUS_BAR, WindowManager.LayoutParams.TYPE_STATUS_BAR);
3. Achieve a single activity remove the title bar
Copy Code code as follows:
Requestwindowfeature (Window.feature_no_title);
1, change the title content: public void Settitle (charsequence title)
2, Hidden title: Requestwindowfeature (Window.feature_no_title);
3, hidden title and the top of the battery charge and signal bar (full screen):
Copy Code code as follows:
public void Setfullscreen () {
Requestwindowfeature (Window.feature_no_title);
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
4, custom title content
Copy Code code as follows:
<activity android:name= ". Activity. Mainactivity "android:screenorientation=" Portrait "android:label=" "@string/titlebar_text"
</actibity> 2)
Mainactivity file:
Copy Code code as follows:
Requestwindowfeature (Window.feature_no_title);
Set window no title bar
Setcontentview (R.layout.main);
Dynamically sets the value of the caption, the value of GetTitle () is the value of the Android:label in the activity's declaration
((TextView) Findviewbyid (R.id.titlebar_text)). SetText (GetTitle ());
The value of the GetTitle () is the value of the android:label= "@string/titlebar_text" above
5, custom title layout
Copy Code code as follows:
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Preset window states that are allowed to change are called before Setcontentview, otherwise a run-time error is thrown when you set the caption.
Requestwindowfeature (Window.feature_custom_title);
Setcontentview (R.layout.custom_title);
The title area can be set to layout, so you can have a rich presentation
GetWindow (). Setfeatureint (Window.feature_custom_title,
R.layout.custom_title_1);
}
Res\layout\custom_title_1.xml contains a textview for displaying headings. Android can be a layout to show the title as a good extensibility.
Copy Code code as follows:
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/" Android "android:id=" @+id/screen "
android:layout_width=" fill_parent "
android:layout_height=" Fill_parent " br>android:orientation= "vertical" >
<textview android:id= "@+id/left_text"
android:layout_width= "wrap" _content "
android:layout_height=" wrap_content "
android:layout_alignparentleft=" true "
android:text=" @ String/custom_title_left "/>
</RelativeLayout>