I'm looking for a way to use DisplayCutoutCompat
since I want to know the height of the notch of the device to move the layout.
The documentation does not really point out how to get an instance within the onCreate method.
You can do it using ViewCompat like below
ViewCompat.setOnApplyWindowInsetsListener(yourView, new OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) {
//This is where you get DisplayCutoutCompat
windowInsetsCompat.getDisplayCutout();
return windowInsetsCompat;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With