mirror of https://github.com/beemdevelopment/Aegis
Apply window insets to prevent UI elements from going behind system windows.
parent
337cb74f72
commit
6039cfa20e
@ -0,0 +1,26 @@
|
||||
package com.beemdevelopment.aegis.helpers;
|
||||
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
|
||||
public class ViewHelper {
|
||||
private ViewHelper() {
|
||||
|
||||
}
|
||||
|
||||
public static void setupAppBarInsets(AppBarLayout appBar) {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(appBar, (targetView, windowInsets) -> {
|
||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
|
||||
targetView.setPadding(
|
||||
insets.left,
|
||||
insets.top,
|
||||
insets.right,
|
||||
0
|
||||
);
|
||||
return WindowInsetsCompat.CONSUMED;
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue