Fix black bar on cutout side after device rotation#1938
Open
rybnikov wants to merge 1 commit intoDrKLO:masterfrom
Open
Fix black bar on cutout side after device rotation#1938rybnikov wants to merge 1 commit intoDrKLO:masterfrom
rybnikov wants to merge 1 commit intoDrKLO:masterfrom
Conversation
In landscape orientation, the display cutout moves to a long edge of the screen. With windowLayoutInDisplayCutoutMode set to shortEdges, the system prevents the window from extending into the cutout area on long edges, leaving a black bar. Two changes fix this: 1. Set windowLayoutInDisplayCutoutMode to "always" (API 30+) so the window extends into the cutout area on all edges, not just short ones. 2. Stop DrawerLayoutContainer from voluntarily avoiding the cutout: remove displayCutout() from the inset types used to calculate child margins and to draw black background rects. The content now fills the full screen area including behind the cutout.
06c48cd to
628dd8b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On devices with a display cutout (notch/punch-hole camera), a black bar appears on the cutout side in landscape orientation. The app interface doesn't extend to the full screen area — the cutout region stays black.
Root cause
Two issues combine to create the black bar:
windowLayoutInDisplayCutoutModeis set toshortEdges— this only allows the window to extend into the cutout area on short edges of the screen. In landscape, the cutout is on a long edge, so the system prevents the window from rendering there.DrawerLayoutContainervoluntarily avoids the cutout — it includesWindowInsetsCompat.Type.displayCutout()when calculating child view margins and draws black rectangles over the cutout areas inonDraw(). Even if the window mode allowed rendering there, the container would still push content away and fill the gap with black.Fix
Change
windowLayoutInDisplayCutoutModefromshortEdgestoalwaysin v31 styles, so the window extends into the cutout area on all edges (API 30+).Remove
displayCutout()from the inset types used inDrawerLayoutContainerfor child margin calculation and background drawing. Content now fills the full screen including behind the cutout.