- 前言
由于Android 高版本的类型限制,如果我们使用WindowsManager 做悬浮窗,会被限制在当前窗口内容中。而当前窗口大小会限制在状态栏和导航栏之间,所以会导致悬浮窗沉浸不了状态栏。
高版本windowsmanager 限制 源码
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//6.0+
mParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} else {
mParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
}
/**
* Window type: Application overlay windows are displayed above all activity windows
* (types between {@link #FIRST_APPLICATION_WINDOW} and {@link #LAST_APPLICATION_WINDOW})
* but below critical system windows like the status bar or IME.
* <p>
* The system may change the position, size, or visibility of these windows at anytime
* to reduce visual clutter to the user and also manage resources.
* <p>
* Requires {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission.
* <p>
* The system will adjust the importance of processes with this window type to reduce the
* chance o

本文探讨了Android高版本下如何突破WindowsManager限制,实现悬浮窗沉浸状态栏。通过详解权限、WindowType和关键代码,教你如何设置透明、权限和参数,以及利用LayoutParams布局策略来达到沉浸效果,包括状态栏高度的获取方法。
最低0.47元/天 解锁文章
1477

被折叠的 条评论
为什么被折叠?



