B4A Library Immersive Mode - Hide system bars

Based on: https://www.b4x.com/android/forum/threads/immersive-mode-hide-the-navigation-bar.90882/#content


Sample Code:
Sub Globals
    Dim immersive As ImmersiveMode
End Sub

Sub Activity_Create(FirstTime As Boolean)
    immersive.Initialize(Activity)
    Activity.LoadLayout("Layout")
End Sub

Sub Activity_WindowFocusChanged(HasFocus As Boolean)
    If HasFocus Then
        immersive.SetMode(immersive.SYSTEM_UI_FLAG_FULLSCREEN)
    End If
End Sub

Manifest:
SetApplicationAttribute(android:theme, "@style/CustomTheme")

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

Manifest (AppCompat):
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">#20A39B</item>
        <item name="colorPrimaryDark">#20A39B</item>
        <item name="colorAccent">#20A39B</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
    </style>
</resources>
)
 

Attachments

  • ImmersiveMode.jar
    8.8 KB · Views: 31
  • ImmersiveMode.xml
    7 KB · Views: 31
Last edited:

Claude Obiri Amadu

Member
Licensed User
Longtime User
Top