Android Application Form Display status action (Requestwindowfeature () application) (reproduced)

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/salam/archive/2010/11/30/1892143.html

We are developing programs that often require full screen display of software, custom titles (using controls such as buttons) and other requirements, and today this is how to control the form display of Android applications.

First of all, an important approach is requestwindowfeature (Featrueid), which is the ability to enable the extended nature of the form. Parameters are constants defined in the window class.

One, enumeration constants

1.default_features: System default state, generally do not need to specify

2.feature_context_menu: Enable ContextMenu, which is enabled by default, generally does not need to specify

3.feature_custom_title: Custom caption. You must specify when you want to customize the caption. such as: When the caption is a button

4.feature_indeterminate_progress: Indeterminate Progress

5.feature_left_icon: Icon to the left of the title bar

6.feature_no_title: Wu Title

7.feature_options_panel: Enable the Options Panel feature, which is enabled by default.

8.feature_progress: Progress indicator function

9.feature_right_icon: Icon to the right of the title bar

Second, detailed

Default display Status

Figure 1 Default

1.feature_custom_title detailed

This.requestwindowfeature (Window.feature_custom_title);
Setcontentview (R.layout.main);

Figure 2 Untitled

This is because Featrue is not set

After the above code add: GetWindow (). Setfeatureint (Window.feature_custom_title, r.layout.title);

 

Figure 3 Customizing the title

Custom caption completion, which is an XML file layout

Title.xml

<?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>

3.feature_indeterminate_progress detailed

Indicates that a process is running

Figure 4 Title progress bar display

Implementation code

1.progress.xml

<?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";
Span style= "color: #ff0000;" >  <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>

2.Java code

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 detailed

Display icon on the left

Figure 5

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 detailed

Available 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);

Figure 6 Full-screen display

Android Application Form Display status action (Requestwindowfeature () application) (reproduced)

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.