We are developing programs that often require full-screen display of software, define their own titles (using controls such as buttons) and other requirements, and today this is how to control the window display of Android applications.
First of all, an important method is Requestwindowfeature (Featrueid), which is the function of enabling the window's extended feature.
The 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: Define the title yourself. You must specify when you need to define the title yourself. such as: When the caption is a button
4.feature_indeterminate_progress: Indeterminate Progress
5.feature_left_icon: Icon on the left side 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 on the right side of the title bar
Ii. Specific explanations
Default display Status
Figure 1 Default
1.feature_custom_title Specific explanations
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 Self-defined title
Define your own title complete, it 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 Specific explanations
Indicates that a process is executing
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" >
<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 Specific explanations
Left side Display icon
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 Specific explanations
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);
Android App window display status action (Requestwindowfeature () app)