How to display a fullscreen TYPE_SYSTEM_ALERT window?

前端 未结 2 936
忘了有多久
忘了有多久 2020-12-08 23:36

I\'m currently having a hard time displaying a TYPE_SYSTEM_ALERT window in fullscreen mode. I\'d like to do so in order to have an overlay view, created from a service, on t

相关标签:
2条回答
  • 2020-12-09 00:14

    I found the solution while trying to do something else!

    In order to have a TYPE_SYSTEM_ALERT window on top of every other window AND on top of the status bar you must add the FLAG_LAYOUT_IN_SCREEN flag and not the FLAG_LAYOUT_FULLSCREEN flag :

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);
    
    mWindowManager.addView(mOverlayView, params);
    
    0 讨论(0)
  • 2020-12-09 00:14

    It doesn't work anymore in Ice Cream Sandwich. The Status bar covers a TYPE_SYSTEM_ALERT window. But TYPE_SYSTEM_OVERLAY still works fine.

    0 讨论(0)
提交回复
热议问题