I have used the `WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY` and `WindowManager.LayoutParams.TYPE_PHONE` attributes to create an overlay for my application. However, I don’t want it to appear above all other windows. Instead, I want it to behave like with the settings window, where it remains underneath other active windows. How can I achieve this?
my code:
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
Right now, the overlay appears on top of other apps, like here:
https://i.sstatic.net/2frpnbfM.png
I want it to look like this, where it disappears when another app is opened:
https://youtu.be/IfZLXIq3Zm0
You need to sign in to view this answers
Leave feedback about this