windowmanager.layoutparams
时间: 2023-04-24 15:00:10 浏览: 167
WindowManager.LayoutParams是Android中的一个类,它用于定义窗口布局的参数。该类中包含了窗口的位置、大小、对齐方式、层级等信息。应用程序可以使用这些参数来控制窗口的显示方式。
相关问题
WindowManager.LayoutParams.privateFlags
WindowManager.LayoutParams.privateFlags is a set of private flags used by the WindowManager to control various aspects of a window. These flags are not intended to be used by applications and are subject to change without notice. Some of the commonly used private flags are:
- FLAG_PREVENT_WALLPAPER - If set, this flag prevents the window from being displayed behind the wallpaper.
- FLAG_SHOW_WHEN_LOCKED - If set, this flag allows the window to be shown even when the device is locked.
- FLAG_SYSTEM_ERROR - If set, this flag indicates that the window represents a system error dialog.
- FLAG_LAYOUT_NO_LIMITS - If set, this flag indicates that the window should be laid out without any constraints.
- FLAG_HARDWARE_ACCELERATED - If set, this flag indicates that the window should be hardware accelerated.
It is important to note that using private flags can be risky as they may not be supported on all devices or may change in future versions of the platform. It is recommended to use the public flags defined in the WindowManager.LayoutParams class instead.
layoutParams = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, height, WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, PixelFormat.TRANSLUCENT ); layoutParams.setTitle("AllApplistWindow"); layoutParams.setFitInsetsTypes(0); layoutParams.windowAnimations = 0; layoutParams.gravity = Gravity.TOP; windowManager.addView(contentView,layoutParams);
这段代码是用来创建一个浮动窗口,并将其添加到屏幕上显示。其中,WindowManager.LayoutParams是用来设置浮动窗口的属性,包括宽度、高度、类型、标志、透明度等等。这里设置的类型为TYPE_NAVIGATION_BAR_PANEL,表示在导航栏上方显示。标志位中的FLAG_NOT_FOCUSABLE表示该窗口不需要获取焦点,FLAG_NOT_TOUCH_MODAL表示该窗口不会拦截事件,FLAG_WATCH_OUTSIDE_TOUCH表示该窗口会检测外部的触摸事件,FLAG_SPLIT_TOUCH表示该窗口支持多点触控。接着设置了窗口的标题、适合插入的区域类型、动画、重力等属性。最后,将要显示的视图contentView和LayoutParams添加到windowManager中,就可以显示出浮动窗口了。
阅读全文