Saik
Saik

Reputation: 1065

Android draw TYPE_APPLICATION_OVERLAY window under status bar

I understand that in SDK >= 26, we can`t draw over the status bar but how can I make my view (TYPE_APPLICATION_OVERLAY) full screen and go under the status bar?

I know that the draw overview of some apps (Like messenger) is able to draw under the status bar but no matter what I try, my overlay always stops at the status bar.

Upvotes: 1

Views: 972

Answers (2)

yorklift
yorklift

Reputation: 41

This is actually caused by Android avoiding cutouts by default and not the status bar per se. This can be seen by running code without the offset workaround given in @saik's answer on a phone that doesn't have cutouts.

As of Android 30 you can use LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS to prevent Android from avoiding the cutout area instead of using the offset workaround.

Upvotes: 2

Saik
Saik

Reputation: 1065

Wow, after 20 hours of searching, it turned out I could use the LayoutParams.FLAG_LAYOUT_NO_LIMITS and put the yPos to a negative number to achieve the desired effect.

Upvotes: 2

Related Questions