Android Full Screen Remove the title bar a variety of implementation methods _android

Source: Internet
Author: User
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>
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.