Skip to content

Commit d169ffb

Browse files
committed
Fix edge to edge layout for API 28+29
1 parent c8f0d7d commit d169ffb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

app/src/main/java/de/stephanlindauer/criticalmaps/Main.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ public void onCreate(Bundle bundle) {
111111
// Setup windows inset handling
112112
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
113113

114+
if (Build.VERSION.SDK_INT >= 28) {
115+
final int newMode = Build.VERSION.SDK_INT >= 30
116+
? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
117+
: WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
118+
final WindowManager.LayoutParams attrs = getWindow().getAttributes();
119+
if (attrs.layoutInDisplayCutoutMode != newMode) {
120+
attrs.layoutInDisplayCutoutMode = newMode;
121+
getWindow().setAttributes(attrs);
122+
}
123+
}
124+
114125
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
115126
getWindow().setStatusBarContrastEnforced(false);
116127
getWindow().setNavigationBarContrastEnforced(false);

app/src/main/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<item name="colorOnSurface">@color/colorOnSurface</item>
2323
<item name="colorError">@color/colorError</item>
2424
<item name="colorOnError">@color/colorOnError</item>
25-
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="27">always</item>
25+
2626
<item name="android:statusBarColor">@android:color/transparent</item>
2727
<item name="android:navigationBarColor">@android:color/transparent</item>
2828
</style>

0 commit comments

Comments
 (0)