Multiple implementation methods for removing the title bar from full screen for android

Source: Internet
Author: User

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>

Related Article

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.