WindowManager. Properties of the Layoutparams
When we want to implement the lock screen function, we need to use WindowManager at this time. Layoutparams, it is necessary to understand his related attributes.
Here is the lock screen code:
WindowManager. LayoutparamsLayoutparams=new WindowManager. Layoutparams(WindowManager. Layoutparams. MATCH_parent, WindowManager. Layoutparams. MATCH_parent);Layoutparams. Flags= WindowManager. Layoutparams. FLAG_fullscreen| WindowManager. Layoutparams. FLAG_layout_in_screen| WindowManager. Layoutparams. TYPE_system_alert| WindowManager. Layoutparams. FLAG_keep_screen_on;Layoutparams. x=0;Layoutparams. Y=0;View view= Layoutinflater. from(Getapplicationcontext ()). Inflate(R. Layout. Window, null);Button button= (button) view. Findviewbyid(R. ID. Button);WindowManager. AddView(View,layoutparams);
Lock Screen Effect:
layoutparams Common Properties:
1.pulibc int x如果忽略gravity属性,那么他表示窗口的绝对X位置2.public int y如果忽略gravity属性,那么他表示窗口的绝对y位置3.public float horizontalWeight public float verticalWeight为关联的View预留多少扩展空间4.public int types窗口类型
The type value is detailed:
The application window. public static final int first_application_window = 1; The "Base" window of all program windows, the other application windows are displayed above it. public static final int type_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 int type_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 int type_application_starting = 3; The application window ends. public static final int last_application_window = 99; child window. The z-order and coordinate space of the child windows are dependent on their host window. public static final int first_sub_window = 1000; A panel window that appears on top of the host window. public static final int type_application_panel = First_sub_window; Media window, such as video. Appears below the host window. public static final int type_application_media = first_sub_window+1; The sub-panel of the application window. Appears on top of all panel windows. (The general law of the GUI, the more "son" more up) public static final int type_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 int type_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. (for example, display subtitles) public static final int Type_Application_media_overlay = First_sub_window +4; The child window ends. (End of types of sub-windows) public static final int last_sub_window= 1999; System window. Non-application creation. public static final int first_system_window= 2000; 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 int type_status_bar= First_system_window; Search bar. There can be only one search bar, which is located above the screen. public static final int type_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 int type_phone= first_system_window+2; System prompts. It always appears on top of the application window. public static final int type_system_alert = First_system_window +3; Lock Screen window. public static final int type_keyguard = First_system_window +4; Information window. Used to display toast. public static final int type_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 int type_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 int type_priority_phone= First_system_window +7; System dialog box. (such as the volume adjustment box). public static final int Type_sysTem_dialog = First_system_window +8; The dialog box that appears when you lock the screen. public static final int type_keyguard_dialog = First_system_window +9; System internal error message, displayed on all content. public static final int type_system_error = First_system_window +10; 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 int type_input_method = First_system_window +11; The internal Input Method dialog box appears above the current Input Method window. public static final int type_input_method_dialog= First_system_window +12; Wallpaper window. public static final int type_wallpaper = First_system_window +13; Slide panel of the status bar. public static final int type_status_bar_panel = First_system_window +14; The system window ends. public static final int last_system_window = 2999;5. public int memorytype; Indicates the type of memory buffer used by the window. The default is NORMAL. The following defines the value of the Memorytype: The window buffer is located in main memory. public static final int memory_type_normal = 0; The window buffer is located in a memory area that can be accessed by DMA or hardware acceleration. public static final int memory_type_hardware = 1; The window buffer is located in an area that can be accessed by the graphics accelerator. public static final int memory_type_gpu = 2; The window buffer does not have its own buffer and cannot be locked. Buffers are provided by local methods. public static final int memory_tYpe_push_buffers = 3;6. public int flags; Behavior Options/flags, default to None. The following defines the value of flags: The contents of the window are dimmed. public static final int flag_dim_behind = 0x00000002; The content after the window becomes blurred. public static final int flag_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 int flag_not_focusable = 0x00000008; Touch screen events are not accepted. public static final int flag_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 int flag_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 int flag_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 int flag_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 int Flag_layout_in_screen =0x00000100; Allow the window to extend beyond the screen. public static final int flag_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 int flag_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 int flag_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 int flag_dither = 0x00001000; Screen is not allowed. public static final int flag_secure = 0x00002000; A special mode in which layout parameters are used to indicate the scale of the display. public static final int flag_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 int flag_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 int flag_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 int flag_alt_focusable_im = 0x00020000; If you set the Flag_nOt_touch_modal, a Motionevent.action_outside event can be received by setting this flag when a touchscreen event occurs outside the window. Note that you will not receive the full Down/move/up event, only the first down event can receive action_outside. public static final int flag_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 int flag_show_when_locked = 0x00080000; The request system wallpaper is displayed behind your window. The window must be translucent. public static final int flag_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 int flag_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 int flag_dismiss_keyguard = 0x00400000; When the lock screen fades out, it continues to run its animation. public static final int flag_keep_surface_while_animating =0x10000000; Displays the window in its original size. Used to run the program in compatibility mode. public static final int flag_compatible_window = 0x20000000; for system dialog boxes. The window that sets this option will receive the focus unconditionally. public static final int flag_system_error = 0x40000000;7. public int softinputmode; Soft input modeOptions: The following options are related to Softinputmode: soft-input areas are visible. public static final int soft_input_mask_state = 0x0f; No state was specified. public static final int soft_input_state_unspecified = 0; Do not modify the state of the soft input region. public static final int soft_input_state_unchanged = 1; Hides the input region (when the user enters the window). public static final int soft_input_state_hidden = 2; Hides the input region when the window receives focus. public static final int soft_input_state_always_hidden = 3; Displays the input region (when the user enters the window). public static final int soft_input_state_visible = 4; Displays the input region when the window receives focus. public static final int soft_input_state_always_visible = 5; The window should be actively adjusted to fit the soft input window. public static final int soft_input_mask_adjust = 0xf0; If no state is specified, the system attempts to select an input method style based on the contents of the window. public static final int soft_input_adjust_unspecified = 0x00; When the input method is displayed, the window is allowed to recalculate dimensions so that the content is not overwritten by the input method. Cannot be mixed with Soft_input_adjusp_pan, if two are not set, the system will automatically set an option based on the contents of the window. public static final int soft_input_adjust_resize = 0x10; The IME displays when the Panning window is displayed. It does not need to handle dimensional changes, and the framework can move the window to ensure that the input focus is visible. Cannot be mixed with soft_input_adjust_resize; if none of the two is set, an option is automatically set according to the contents of the window. public static final int Soft_inpuT_adjust_pan = 0x20; When the user goes to this window, it is set automatically by the system, so you do not set it. The flag is automatically cleared when the window is displayed. public static final int soft_input_is_forward_navigation = 0x100;8. public int gravity; The Gravity property. What is the gravity attribute? Simply put, it's how the window docks. 9. public float HorizontalMargin; The horizontal margin, the distance between the container and the widget, which is the percentage of the container width. public float VerticalMargin; longitudinal margins. One. public int format; the expected bitmap format. The default is opaque. Refer to Android.graphics.PixelFormat. public int windowanimations; the animation settings used by the window. It must be a system resource, not an application resource, because the window manager cannot access the application. public float alpha = 1.0f; The translucent value of the entire window, 1.0 for opacity, and 0.0 for full transparency. public float dimamount = 1.0f; When Flag_dim_behind is set, it takes effect. The variable indicates the degree to which the subsequent window darkens. 1.0 means completely opaque, and 0.0 means no darkening. public float screenbrightness = -1.0f; the screen brightness used to override user settings. Represents the screen brightness of the app user settings. Adjusts the brightness from 0 to 1 to change from dark to brightest. IBinder Public token = null, window designator. (Identifier for the This window.) This would usually is filled in for you. ) 17. Public String packagename = null; the package name in which this window resides. public int screenorientation =activityinfo.screen_orientation_unspecified; Screen orientation, see android.content.pm.activityinfo#screenorientation. 19. In compatibility mode, the backup/restore parameters are usedThe internal buffer. Public int[] Mcompatibilityparamsbackup = null;
Android-windowmangerlayoutparams Properties