Giter VIP home page Giter VIP logo

Comments (2)

wlwanglun avatar wlwanglun commented on July 20, 2024 1

wl = WindowManager.LayoutParams().apply {
width = helper.layoutParams?.width ?: WindowManager.LayoutParams.MATCH_PARENT
height = helper.layoutParams?.height ?: WindowManager.LayoutParams.MATCH_PARENT
format = PixelFormat.TRANSLUCENT
gravity = (Gravity.TOP or Gravity.START)
// 设置需要覆盖的系统窗口
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
// 如果是Android 11及以上,需要额外设置
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
}
flags = (WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
or WindowManager.LayoutParams.FLAG_FULLSCREEN
or WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
or WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
)
type =
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY

    }

可以了

from floatingx.

Petterpx avatar Petterpx commented on July 20, 2024

我把FxSystemContainerView 默认改成MATCH_PARENT wl = WindowManager.LayoutParams().apply { width = helper.layoutParams?.width ?: WindowManager.LayoutParams.MATCH_PARENT height = helper.layoutParams?.height ?: (WindowManager.LayoutParams.MATCH_PARENT + 5000) format = PixelFormat.RGBA_8888 gravity = Gravity.TOP or Gravity.START // 设置需要覆盖的系统窗口 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES } // 如果是Android 11及以上,需要额外设置 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS } flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_FULLSCREEN type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY }

试试这样呢

wl = WindowManager.LayoutParams().apply {
            width = helper.layoutParams?.width ?: WindowManager.LayoutParams.WRAP_CONTENT
            height = helper.layoutParams?.height ?: WindowManager.LayoutParams.WRAP_CONTENT
            format = PixelFormat.RGBA_8888
            gravity = Gravity.TOP or Gravity.START
            flags =
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or
                        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
                        WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or
                        WindowManager.LayoutParams.FLAG_FULLSCREEN or
                        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or
                        WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS

            type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
            } else {
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
            }
        }

from floatingx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.