Android Application Form display status operation (Application of requestwindowfeature)

Source: Internet
Author: User

During development, full screen display, custom titles (using buttons and other controls), and other requirements are often required. Today we will talk about how to control the form display of Android applications.

First, we will introduce an important method: requestwindowfeature (featrueid). Its function is to enable extended form features. A parameter is a constant defined in the window class.

I. Enumeration Constants

1. default_features: default system status, which is not required

2. feature_context_menu: Enable contextmenu. This option is enabled by default. Generally, you do not need to specify

3. feature_custom_title: Custom title. You must specify a custom title. For example, when the title is a button

4. feature_indeterminate_progress: uncertain progress

5. feature_left_icon: icon on the left of the title bar

6. feature_no_title: No title

7. feature_options_panel: enables the option panel function. It is enabled by default.

8. feature_progress: Progress indicator Function

9. feature_right_icon: icon on the right of the title bar

 

 

Custom title bar content: getwindow (). setfeatureint (window. feature_custom_title, R. layout. Title );

 

<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout
Xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content">

<Imageview Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: src = "@ drawable/icon"/>
<Textview Android: Id = "@ + ID/text"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_alignparentleft = "true"
Android: text = "text"/>

</Linearlayout>

 

Feature_indeterminate_progress

Indicates that a process is running.

 

<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout
Xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content">
<Progressbar Android: Id = "@ + ID/progress"

Android: layout_width = "wrap_content"

Android: layout_height = "wrap_content"

Android: layout_gravity = "center_vertical"
Style = "? Android: ATTR/progressbarstylesmalltitle ">

</Progressbar>
</Linearlayout>

 

This. requestwindowfeature (window. feature_indeterminate_progress );
Setcontentview (R. layout. Main );

Getwindow (). setfeatureint (window. feature_indeterminate_progress, R. layout. Progress );
Setprogressbarindeterminatevisibility (true );

 

 

3. feature_left_icon

Icon displayed on the left

 

Implementation Code

This. requestwindowfeature (window. feature_left_icon );
Setcontentview (R. layout. Main );

Getwindow (). setfeaturedrawableresource (window. feature_left_icon, R. drawable. Icon );

 

 

4. feature_no_title

Can be used for Full Screen Display

 

Implementation Code

This. requestwindowfeature (window. feature_no_title );
Setcontentview (R. layout. Main );
 
Getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen );

 

 

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.