Android Question Smartphones with a notch


Active Member
Licensed User
Longtime User
Following the tutorial here I was able to display the application in full screen Iimmersive mode), including over the notch area.
It is possible to set the option (cover/not cover notch area0 from the code, not from the Manifest file?

Some smartphones can have a bigger notch and then to cover used areas on the screen, so I want the user to be able to decide.

Thank you.


Active Member
Licensed User
Longtime User
I successfully achieved this. What I still have to do when I will have some more time is to automatically detect notch position. Currently the user choose manually the notch position (center, left or right). This help positioning some screen elements based on selection.

CreateResource(values, theme.xml,
    <style name="CustomTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>

    Dim iDisplayNotch As Int
    Dim NOTCH_NEVER As Int = 0
    Dim NOTCH_ALWAYS As Int = 1
    Dim NOTCH_LEFT As Int = 2
    Dim NOTCH_RIGHT As Int = 3
    Dim NOTCH_SIDE As Int = 4
    Dim LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS As Int = 3          ' The window is always allowed to extend into the DisplayCutout areas on the all edges of the screen.
    Dim LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT As Int = 0         ' The window is allowed to extend into the DisplayCutout area, only if the DisplayCutout is fully contained within a system bar. Otherwise, the window is laid out such that it does not overlap with the DisplayCutout area
    Dim LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER As Int = 2             ' The window is never allowed to overlap with the DisplayCutout area
    Dim LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES As Int = 1    ' The window is always allowed to extend into the DisplayCutout areas on the short edges of the screen even if fullscreen or in landscape. The window will never extend into a DisplayCutout area on the long edges of the screen.
    Dim Ph as Phone
Get the height of the notch (o if no notch):
Sub GetNotchHeight As Int
    ' find if the display has a notch and return his height
    ' if no notch, return 0
    If SDKver < 28 Then Return 0
    Dim ctxt As JavaObject

    Dim JO As JavaObject = ctxt.RunMethodJO("getWindow", Null)
    JO = JO.RunMethodJO("getDecorView", Null)
    JO = JO.RunMethodJO("getRootWindowInsets",Null)
    JO = JO.RunMethodJO("getDisplayCutout",Null)

    If JO.IsInitialized Then
        Log("This device has a notch")
        Dim i As Int = JO.RunMethod("getSafeInsetTop",Null)
        Log("Notch Height: " & i)
        Return i
        Log("This device does not have a notch")
        Return 0
    End If
End Sub
First check if the smartphone has a notch.
        If Ph.SdkVersion>= 28 Then
            Dim jo As JavaObject
            jo = jo.RunMethod("getWindow", Null)
            jo.RunMethodJO("getAttributes", Null).SetField("layoutInDisplayCutoutMode",LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)
            If GetNotchHeight > 0 Then
                bIsNotch = True
                bIsNotch = False
            End If
            If iDisplayNotch = NOTCH_NEVER Then
                jo.RunMethodJO("getAttributes", Null).SetField("layoutInDisplayCutoutMode", LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER)
                jo.RunMethodJO("getAttributes", Null).SetField("layoutInDisplayCutoutMode",LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)
            End If
        End If

Hope this helps others interested in this topic.
Upvote 0


Active Member
Licensed User
Longtime User
Would you please give some more details on the lines 11 and following. What is iDisplayNotch used for? Where is a value set for it?
I think it is used to store the state of the Display Cutout Mode before manipulating it in line 5. Right? But where do you set this value?
Upvote 0


Active Member
Licensed User
Longtime User
I use iDisplayNoth to store notch position. As I don't think is possible to automatically detect notch position, the user set position from the app menu.
Then is used to know where not to display GUI elements. The user can opt not to use notch area at all.
Notch can be a simple punch hole for the front facing camera that is positioned in the top left, top right or in the top middle.
Upvote 0