How can I get the height of recent android phones' notch, preferably in pixels?
I have an implementation where an image MUST be at the top in full screen.
With the addition of a notch to recently released phones, this image will be cut out by the notch. My idea is to get the notch height and add a margin above it dynamically to accommodate different notch sizes.
Any help or other approaches would be greatly appreciated.
I used the method below(in Kotlin):
*It will only work in Android P and above.
*My activity is a full screen activity.
*My assumption is android phone with notches are relatively new will either come out of the box with Android P or have been rapidly updated to Android P.
Create a OnGlobalLayoutListener
Add the listener to your activity's rootview using .viewTreeObserver.addOnGlobalLayoutListener()
My layout xml where layout_fullscreen is the rootview.