Android window. requestWindowFeature () Common Methods

Source: Internet
Author: User

I recently saw an article on the Internet about how to use requestWindowFeature () in android windows.

RequestWindowFeature (Window. FEATURE_LEFT_ICON );
SetContentView (R. layout. dialog_activity );
GetWindow (). setFeatureDrawableResource (Window. FEATURE_LEFT_ICON, android. R. drawable. ic_dialog_alert );

Android Application Form display status operation (Application of requestWindowFeature)

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, an important method is introduced.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

Ii. Details

1. Default display status

2. FEATURE_CUSTOM_TITLE

This. requestWindowFeature (Window. FEATURE_CUSTOM_TITLE );
SetContentView (R. layout. main );

This is because Featrue is not set.

After the code above, add: getWindow (). setFeatureInt (Window. FEATURE_CUSTOM_TITLE, R. layout. title );

The custom title is complete. It is an xml file layout.

Title. xml

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.