Implement full-screen code:
Obviously, the first sentence is to close the title bar, and the second sentence is to close the status bar.
However, this is not enough in-depth, we from the source analysis.
First, requestwindowfeature () The source code:
/** * Enable Extended window features. This was a convenience for calling * {@link android.view.window#requestfeature GetWindow (). Requestfeature ()}. * * @param featureid the desired feature as defined in * {@link Android.view.Window}. * @return Returns True if the requested feature is supported and now * enabled. * * @see android.view.window#requestfeature * /Public Final Boolean requestwindowfeature (int Featureid) { return GetWindow (). Requestfeature (Featureid); }
From the above we know that the function of this method is directly equivalent to GetWindow (). Requestfeature (), which is the convenient way to invoke the latter. The parameter is the int tag of the Tag Window feature under Window class, returns the Boolean value, and if true, indicates that the characteristic passed by parameter is supported and implemented.
Let us look at the types of window features defined under the Windows class:
/** * Abstract base class for a top-level windows look and behavior policy. An * instance of this class should is used as the top-level view added to the * window manager. IT provides standard UI policies such as a background, title * area, default key processing, etc. * * <p>the only EX Isting implementation of this abstract class was * Android.policy.PhoneWindow, which you should instantiate when needing a * Window. Eventually that class would be refactored and a factory method * added for creating Windows instances without knowing about A particular * implementation. */public Abstract class Window {/** Flag for the "Options panel" feature. This is enabled by default. */public static final int feature_options_panel = 0; /** Flag for the ' No title ' feature, turning off the title at the top * of the screen. */public static final int feature_no_title = 1; /** Flag for the progress indicator feature */public static final int feature_progress = 2; /** Flag for have a icon on the left side of the title bar */public static final int feature_left_icon = 3; /** Flag for have an icon on the right side of the title bar */public static final int feature_right_icon = 4; /** Flag for Indeterminate progress */public static final int feature_indeterminate_progress = 5; /** Flag for the context menu. This is enabled by default. */public static final int feature_context_menu = 6; /** Flag for custom title. You cannot combine this feature with the other title features. */public static final int feature_custom_title = 7; /** * Flag for enabling the Action Bar. * This was enabled by the default for some devices. The Action Bar * replaces the title bar and provides an alternate location * For a on-screen menu button on some Devices. */public static final int feature_action_bar = 8; /** * Flag for requesting a Action Bar that overlays window content. * Normally an Action Bar would sit In the space above window content, but if this * feature was requested along with {@link #FEATURE_ACTION_BAR} it'll be Layered over * the window content itself. This was useful if you would like your apps to any of the control * over how the Action Bar is displayed, such as letting Application content Scroll beneath * An Action Bar with a transparent background or otherwise displaying a transparen T/translucent * Action Bar over application content. */public static final int feature_action_bar_overlay = 9; /** * Flag for specifying the behavior of action modes if an action Bar is not present. * If Overlay is enabled, the action mode UI would be allowed to cover existing window content. */public static final int feature_action_mode_overlay = 10; /** Flag for setting the progress bar's visibility to VISIBLE/public static final int progress_visibility_on =-1; /** Flag for setting the progress bar's visibility to GONE * * Public Static Final int progress_visibility_off =-2; /** Flag for setting the progress bar's indeterminate mode on */public static final int progress_indeterminate_on = 3 ; /** Flag for setting the progress bar ' s indeterminate mode off */public static final int progress_indeterminate_off = -4; /** starting value for the (primary) progress */public static final int progress_start = 0; /** ending value for the (primary) progress */public static final int progress_end = 10000; /** Lowest Possible value for the secondary progress */public static final int progress_secondary_start = 20000; /** highest possible value for the secondary progress */public static final int progress_secondary_end = 30000; /** the default features enabled */@SuppressWarnings ({"Pointlessbitwiseexpression"}) protected static final int D Efault_features = (1 << feature_options_panel) | (1 << feature_context_menu); /** * The ID that the mainLayout in the XML layout file should. */public static final int id_android_content = com.android.internal.r.id.content;These are all exposed member variables of the window class.
The following is a summary of the window class: the abstract base class for the appearance and behavior of the top-level window , which is often added to the window manager as a top-level view . It provides standard UI methods such as backgrounds, title areas, and so on.
Note: The only class that implements this abstract class is Android.policy.PhoneWindow, and the class is rewritten and created with a factory schema to create new instances. Generally we call GetWindow directly to get an instance.
The instance of window is also a View object, but this object is at the very bottom, beyond the bounds of our application, and we can look at the view tree of an application in memory for further understanding. In fact, the entire Android system can also be seen as being made up of many applications. The window is no longer being delved into.
Then explain and display the relevant tags in full screen:
/** Flag for the ' No title ' feature, turning off the title at the top * of the screen . */Public static final int feature_no_title = 1;
(PS: I would like to introduce most of the, really a bit more!) )
Then there is requestfeature (), which literally knows the features of getting the appearance of a top-level window . Of course requestwindowfeature () ibid.
Second, setflags (int flags, int mask) source code:
/** * Set The flags of the window, as per the * {@link windowmanager.layoutparams windowmanager.layoutparams} * Flags. * * <p>note that some flags must being set before the window decoration is * created * {@link #setContentView (View, Android.view.ViewGroup.LayoutParams)} or * {@link #getDecorView ()}: * {@link Windo Wmanager.layoutparams#flag_layout_in_screen} and * {@link Windowmanager.layoutparams#flag_layout_inset_decor}. These * 'll be set to the based on the {@link Android. r.attr#windowisfloating} * attribute. * * @param flags The new window flags (see WINDOWMANAGER.LAYOUTPARAMS). * @param mask which of the window flag bits to modify. */public void setflags (int flags, int mask) {final Windowmanager.layoutparams attrs = GetAttributes (); Attrs.flags = (Attrs.flags&~mask) | (Flags&mask); Mforcedwindowflags |= Mask; if (mcallback! = null) {MCAllback.onwindowattributeschanged (ATTRS); } }
Flag is also flags, but why is not the same as the previous sentence, because the object has changed. The front is the window class, and the latter is windowmanager.layoutparams. WindowManager good understanding, is the Window manager, Tube Window object, then Layoutparams:
Layoutparams is used by the views of the their parents how they want is laid out.
This means that this is used to tell their parent how to arrange them. For example, tell Linnerlayout view how to place the Gallery object on top of itself, and tell the window manager how to arrange whether the window is full screen or overflow, etc.
Note: This method, because it is set to the properties of the top-level window, needs to be called before some other method of setting the layout, such as Setcontentview ().
Two parameters meaning: the first one is set to what, the second is set where (byte type).
and the flags specific and which, there are different to represent what kind of window layout characteristics. In the WindowManager category under the Layoutparams, here to take out and Flag_fullscreen related source code:
/** window Flag:allow window to extend outside of the screen. */public static final int flag_layout_no_limits = 0x00000200; /** window Flag:hide all screens decorations (e.g. status bar) While the This window is displayed. This allows the window to use the entire * display space for itself-the status bar would be hidden when * an app window with this flag set is on the top layer. */public static final int Flag_fullscreen = 0x00000400; /** Window flag:override {@link #FLAG_FULLSCREEN and force the * screen decorations (such as status bar) to be Shown. */public static final int Flag_force_not_fullscreen = 0x00000800;
At a glance, you can see the specific implementation of the Setflag () method and Requestfeature () for further understanding.
Thank you ~
"Android Personal Understanding (iii)" From the source anatomy how to achieve full-screen effect