Skip to content

Commit

Permalink
MainActivity.java: add systemBars insets to main view padding
Browse files Browse the repository at this point in the history
  • Loading branch information
rsx authored and not-fl3 committed Jun 17, 2024
1 parent 51b5fb3 commit 44a44a2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion java/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;

import android.graphics.Color;
import android.graphics.Insets;
Expand Down Expand Up @@ -207,7 +208,16 @@ public ResizingLayout(Context context){
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
if (Build.VERSION.SDK_INT >= 30) {
Insets imeInsets = insets.getInsets(WindowInsets.Type.ime());
v.setPadding(0, 0, 0, imeInsets.bottom);
Insets sysInsets = insets.getInsets(WindowInsets.Type.systemBars());

// The sys insets change when orientation changes and sys bars
// change position.
v.setPadding(
sysInsets.left,
sysInsets.top,
sysInsets.right,
imeInsets.bottom + sysInsets.bottom
);
}
return insets;
}
Expand Down

0 comments on commit 44a44a2

Please sign in to comment.