1. implement full screen for all activities in the Application
Add directly to manifest
Copy codeThe Code is as follows: android: theme = "@ android: style/Theme. NoTitleBar. Fullscreen"
2. implement full screen for a single activity Copy codeThe Code is as follows: requestWindowFeature (Window. FEATURE_NO_TITLE );
GetWindow (). setFlags (WindowManager. LayoutParams. TYPE_STATUS_BAR, WindowManager. LayoutParams. TYPE_STATUS_BAR );
3. Remove the title column from a single activity. Copy codeThe Code is as follows: requestWindowFeature (Window. FEATURE_NO_TITLE );
1. Change the title content: public void setTitle (CharSequence title)
2. Hide the title: requestWindowFeature (Window. FEATURE_NO_TITLE );
3. Hide the title and top battery power and signal bar (full screen ):Copy codeThe Code is 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 codeThe Code is as follows: <activity android: name = ". activity. MainActivity" android: screenOrientation = "portrait" android: label = "@ string/titlebar_text"
</Actibity> 2)
In the MainActivity file:Copy codeThe Code is as follows: requestWindowFeature (Window. FEATURE_NO_TITLE );
// Set that the window has no title bar
SetContentView (R. layout. main );
// Set the title value dynamically. The value of getTitle () is the android: label value in the activity declaration.
(TextView) findViewById (R. id. titlebar_text). setText (getTitle ());
The value obtained by getTitle () is the value of android: label = "@ string/titlebar_text ".
5. Custom title Layout Copy codeThe Code is as follows: protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
// Set the window status that can be changed in advance, which must be called before setContentView; otherwise, a running error is thrown when the title is set.
RequestWindowFeature (Window. FEATURE_CUSTOM_TITLE );
SetContentView (R. layout. custom_title );
// The title area can be set to layout, which can be displayed in a variety of ways.
GetWindow (). setFeatureInt (Window. FEATURE_CUSTOM_TITLE,
R. layout. custom_title_1 );
}
Res \ layout \ custom_title_1.xml contains a TextView used to display the title. Android can display the title as a layout with good scalability.Copy codeThe Code is 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"
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>