WindowManager (View master)

Source: Internet
Author: User

WindowManager allows us to add or remove view from the activity.
//这个类主要有三个方法:
WindowManager.addView(view,LayoutParams);WindowManager.removeView(view);WindowManager.updateViewLayout(view,LayoutParams);
:

How to use:
Custom View Final View view = Layoutinflater. from(this). Inflate(R. Layout. View_share, NULL);Get the system windowmanager//final windowmanager Mmanager = (windowmanager) mcontext. Getsystemservice(Context. WINDOW_service);Gets the current page of windowmanagerfinal WindowManager Mmanager = Getwindowmanager ();WindowManager. LayoutparamsMlayoutparams = new WindowManager. Layoutparams();Mlayoutparams. Type= WindowManager. Layoutparams. TYPE_application;Mlayoutparams. Format= PixelFormat. Translucent;Mlayoutparams. Flags= WindowManager. Layoutparams. FLAG_not_focusable;Mlayoutparams. Gravity= Gravity. CENTER;Mlayoutparams. Width= WindowManager. Layoutparams. MATCH_parent;Mlayoutparams. Height= WindowManager. Layoutparams. MATCH_parent;Mmanager. AddView(View, Mlayoutparams);ImageView Mcanceliv = (ImageView) view. Findviewbyid(R. ID. IV_cancel);Mcanceliv. Setonclicklistener(New View. Onclicklistener() {@Override public void OnClick (View v) {Mmanager. Removeview(view);}});
Type Property Constants
The application window. Public Static Final intFirst_application_window =1; The "Base" window of all program windows, the other application windows are displayed above it. Public Static Final intType_base_application =1; General application Function Program window. Token must be set to the activity token to indicate who the window belongs to. Public Static Final intType_application =2; Used for Windows that are displayed when the application starts.    The app itself does not use this type. It is used to let the system display some information until the application can open its own window. Public Static Final intType_application_starting =3; The application window ends. Public Static Final intLast_application_window = About; child window. The z-order and coordinate space of the child windows are dependent on their host window. Public Static Final intFirst_sub_window = +; A panel window that appears on top of the host window. Public Static Final intType_application_panel = First_sub_window; Media window, such as video. Appears below the host window. Public Static Final intType_application_media = first_sub_window+1; The sub-panel of the application window. Appears on top of all panel windows. (The general rule of the GUI, the more "son" more up) Public Static Final intType_application_sub_panel = First_sub_window +2; dialog box. Similar to a panel window, drawing is similar to a top-level window, not a child window of the host. Public Static Final intType_application_attached_dialog = First_sub_window +3; Media information. Appears between the media layer and the program window, and you need to implement transparent (translucent) effects. (e.g. display subtitles) Public Static Final intType_application_media_overlay = First_sub_window +4; The child window ends. (End of types of sub-windows) Public Static Final intLast_sub_window =1999; System window. Non-application creation. Public Static Final intFirst_system_window = -; Status bar. There can only be one status bar; it is at the top of the screen, and the other windows are underneath it. Public Static Final intType_status_bar = First_system_window; Search bar. There can be only one search bar, which is located above the screen. Public Static Final intType_search_bar = first_system_window+1; Phone window. It is used for telephone interactions (especially inbound). It is placed above all applications, under the status bar. Public Static Final intType_phone = first_system_window+2; System prompts. It always appears on top of the application window. Public Static Final intType_system_alert = First_system_window +3; Lock Screen window. Public Static Final intType_keyguard = First_system_window +4; Information window. Used to display toast. Public Static Final intType_toast = First_system_window +5; The top-level window of the system. is displayed on top of all other content. This window cannot get input focus, otherwise it affects the lock screen. Public Static Final intType_system_overlay = First_system_window +6; The phone takes precedence when the lock screen is displayed. This window cannot get input focus, otherwise it affects the lock screen. Public Static Final intType_priority_phone = First_system_window +7; System dialog box. (such as the volume adjustment box). Public Static Final intType_system_dialog = First_system_window +8; The dialog box that appears when you lock the screen. Public Static Final intType_keyguard_dialog = First_system_window +9; System internal error message, displayed on all content. Public Static Final intType_system_error = First_system_window +Ten; The internal Input Method window is displayed on top of the normal UI. The application can be re-laid out to avoid being overwritten by this window. Public Static Final intType_input_method = First_system_window + One; The internal Input Method dialog box appears above the current Input Method window. Public Static Final inttype_input_method_dialog= First_system_window + A; Wallpaper window. Public Static Final intType_wallpaper = First_system_window + -; Slide panel of the status bar. Public Static Final intType_status_bar_panel = First_system_window + -; The system window ends. Public Static Final intLast_system_window =2999;
Flag Property Constants
The content after the window is dimmed. Public Static Final intFlag_dim_behind =0x00000002; The content after the window becomes blurred. Public Static Final intFlag_blur_behind =0x00000004;    Don't get the spotlight. You cannot get key input focus, so you cannot send a button or button event to it. Those times will be sent to the window behind it to get the focus. This option also sets the Flag_not_touch_modal option. Setting this option means that the window cannot interact with the soft input method, so its z-order is independent of any active input method (in other words, it can be displayed in full screen and can overwrite the IME window if needed). To modify this behavior, refer to the FLAG_ALT_FOCUSALBE_IM option. Public Static Final intFlag_not_focusable =0x00000008; Touch screen events are not accepted. Public Static Final intFlag_not_touchable =0x00000010; When the window can get focus (without setting the FLAG_NOT_FOCUSALBE option), the Point device events (mouse, touch screen) that are outside the window range are still sent to the subsequent window processing. Otherwise it will monopolize all point device events, regardless of whether they occur within the window range. Public Static Final intFlag_not_touch_modal =0x00000020;    If this flag is set, when the device sleeps, tap on the touchscreen and the device will receive this first touch event. Usually the first touch event is consumed by the system, and the user will not see what happens when they click on the screen. Public Static Final intFlag_touchable_when_waking =0x00000040; When this window is visible to the user, keep the device normally open and keep the brightness constant. Public Static Final intflag_keep_screen_on =0x00000080; The window fills the entire screen, ignoring the surrounding decorative borders (such as the status bar). This window takes into account the contents of the decorative border. Public Static Final intFlag_layout_in_screen =0x00000100; Allow the window to extend beyond the screen. Public Static Final intFlag_layout_no_limits =0x00000200; When the window is displayed, hide all of the screen decorations (such as the status bar). Causes the window to occupy the entire display area. Public Static Final intFlag_fullscreen =0x00000400; This option overrides the Flag_fullscreen option and forces the screen decorations (such as the status bar) to pop up. Public Static Final intFlag_force_not_fullscreen =0x00000800; Jitter. Refers to the display method of translucency. Also known as "point through". Devices with poor graphics tend to use "point through" instead of alpha blending. Public Static Final intFlag_dither =0x00001000; Screen is not allowed. Public Static Final intFlag_secure =0x00002000; A special mode in which layout parameters are used to indicate the scale of the display. Public Static Final intflag_scaled =0x00004000; This option prevents the cheek from operating incorrectly on the screen when the screen is likely to have a face attached. Public Static Final intFlag_ignore_cheek_presses =0x00008000; When you request a layout, your window may appear above or below the status bar, causing occlusion. When this option is set, the window manager ensures that the contents of the window are not covered by the trim bar (status bar). Public Static Final intFlag_layout_inset_decor =0x00010000;    Reverses the flag_not_focusable option. If both the flag_not_focusable option and this option are set, the window will be able to interact with the input method, allow the IME window to be overwritten, and if the flag_not_focusable is not set and the option is set, the window cannot interact with the IME and can overwrite the Input method window. Public Static Final intFlag_alt_focusable_im =0x00020000; If you set the Flag_not_touch_modal, then when the touchscreen event occurs outside the window, you can receive a Motionevent.action_outside event by setting this flag. Note that you will not receive the full Down/move/up event, only the first down event can receive action_outside. Public Static Final intFlag_watch_outside_touch =0x00040000; When the screen is locked, the window can be seen. This allows the application window to take precedence over the lock screen. The screen can be lit with the flag_keep_screen_on option and displayed directly before the lock screen. Unlocked lock screen status can be lifted directly using the Flag_dismiss_keyguard option. This option is only available for the topmost full-screen window. Public Static Final intflag_show_when_locked =0x00080000; The request system wallpaper is displayed behind your window. The window must be translucent. Public Static Final intFlag_show_wallpaper =0x00100000; Once the window is displayed, the system will light up the screen just as the user wakes up the device. Public Static Final intflag_turn_screen_on =0x00200000; Unlocks the lock screen. Only the lock screen interface is not encrypted to unlock. If the lock screen is encrypted, the user will not see the window until the flag_show_when_locked option is set. Public Static Final intFlag_dismiss_keyguard =0x00400000; When the lock screen fades out, it continues to run its animation. Public Static Final intFlag_keep_surface_while_animating =0x10000000; Displays the window in its original size. Used to run the program in compatibility mode. Public Static Final intFlag_compatible_window =0x20000000; for system dialog boxes. The window that sets this option will receive the focus unconditionally. Public Static Final intFlag_system_error =0x40000000;

Reference Links:
Windowmanager.layoutparams parameter Learning

WindowManager (View master)

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.