Android Question Auto hide navigation bar at full screen (ZOrder?)

Binary01

Active Member
Licensed User
Longtime User
Hi,

b4a app can not use full screen because navigation bar tool a place at the bottom. I tested app on Huawei tablet android 4.2.2, and other devices that use 4.2.2. But I found some app run on full screen and hide navigation bar automatically. Navigation bar is behind the full screen app.

How can I do my b4a app?

Thanks in advanced.
 

bgsoft

Well-Known Member
Licensed User
Longtime User
You can activate or hide

B4X:
Sub Globals
Dim BarraDeEstadomView As Label
' ----------------
' ----------------
' ----------------

Sub Activity_Create(FirstTime As Boolean)
     BarraDeEstadomView.Initialize("")
     BarraDeEstadomView.Text =""
     QuitarBarraEstatus ' hide

' ----------------
' ----------------
' ----------------

Sub Activity_Pause (UserClosed As Boolean)
  If UserClosed then  PonerBarraEstatus ' Active
' ----------------
' ----------------
' ----------------



Sub QuitarBarraEstatus
  ' Hide
    Dim mlp As JavaObject
    Dim vtype As Int = -1, pixelFormat As Int = -3
   
    Try
      mlp.InitializeNewInstance("android.view.WindowManager$LayoutParams", Array(vtype, 100, 2010,296, pixelFormat))
    Catch
    End Try
   
    Try
      mlp.SetField("gravity", Bit.Or(Gravity.TOP, Gravity.CENTER))
    Catch
    End Try
   
    Try
      Dim windowManager As JavaObject = BarraEstatusGetContext.RunMethod("getSystemService", Array("window"))
    Catch
    End Try
   
    Try
      windowManager.RunMethod("addView", Array(BarraDeEstadomView, mlp))
    Catch
    End Try
   
End Sub



Sub PonerBarraEstatus
  ' Active
    If BarraDeEstadomView.IsInitialized = False Then
        BarraDeEstadomView.Initialize("")
        BarraDeEstadomView.Text =""
    End If
    Try
      Dim windowManager As JavaObject = BarraEstatusGetContext.RunMethod("getSystemService", Array("window"))
      windowManager.RunMethod("removeView", Array(BarraDeEstadomView))
  Catch
    End Try
               
       
       
End Sub

Sub BarraEstatusGetContext As JavaObject
    Return BarraEstatusGetBA.GetField("context")
End Sub

Sub BarraEstatusGetBA As JavaObject
    Dim jo As JavaObject
    Dim cls As String = Me
    cls = cls.SubString("class ".Length)
    jo.InitializeStatic(cls)
    Return jo.GetFieldJO("processBA")
End Sub

Regards
 
Upvote 0

Binary01

Active Member
Licensed User
Longtime User
Thanks BgSoft.

When I run my app, I want navigation bar is hide or behind my full screen app or dimming.



Above image navigation bar is shown although my app run as full screen. I want to show my app full screen and hide navigation bar.
 
Upvote 0

bgsoft

Well-Known Member
Licensed User
Longtime User
I put this code in a Samsung tablet and also added this:
B4X:
#Region  Activity Attributes
#FullScreen: True

the status bar and navigation bar is hidden, it is only my program to full screen

Look at the picture attached

Regards
 

Attachments

  • Screenshot_2016-09-28-12-47-53.png
    296.7 KB · Views: 519
Upvote 0

Binary01

Active Member
Licensed User
Longtime User
Yes, It run on my Samsung Tablet. Most Samsung tablets' navigation keys are existed on body frame physically. (1.jpg)

But most china phone show navigation keys on phone screen. (2.jpg)

So
#Region Activity Attributes#FullScreen: True is ok at Samsung Tablet.

On Huawei tablet, navigation bar is seen 3.jpg

I found the articles as follow:
On Android 4.1 and higher, you can set your application's content to appear behind the navigation bar, so that the content doesn't resize as the navigation bar hides and shows. To do this, use SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION. You may also need to use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain a stable layout.
https://developer.android.com/training/system-ui/navigation.html#behind
https://developer.android.com/training/system-ui/navigation.html#behind
But how can I write code in b4a app?
 

Attachments

  • 1.JPG
    134.6 KB · Views: 621
  • 2.JPG
    235.5 KB · Views: 644
  • 3.JPG
    218.4 KB · Views: 617
Upvote 0

bgsoft

Well-Known Member
Licensed User
Longtime User
Thanks bosoft
I found the solution it's called immersive full-screen mode.

I guess the solution is something like this:
(They are the flag you commented up)

B4X:
         ' available flags:
         'SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 4096 (0x01000)
         'SYSTEM_UI_FLAG_IMMERSIVE = 2048 (0x0800)
         'SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024 (0x0400)
         'SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512 (0x0200)
         'SYSTEM_UI_FLAG_LAYOUT_STABLE = 256 (0x0100)
         'SYSTEM_UI_FLAG_FULLSCREEN = 4 (0x04)
         'SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2 (0x02)
               

   Dim jo As JavaObject = Activity
   jo.RunMethod("setSystemUiVisibility", Array As Object(5894))

Regards
 
Upvote 0

Binary01

Active Member
Licensed User
Longtime User
yes bgsoft

Navigation bar is hide but its space is blank and my app is not truly full-screen. Any advice?
I use Activity.Width and Activity.Height in my code.
 
Upvote 0

bgsoft

Well-Known Member
Licensed User
Longtime User
I have no tablet Chinese (I can not see that problem), I use full screen, and does not leave me blank.
Try one of the flags
You can also set the background color of the activity of your application
You could also place a panel in the blank area
Since we do not employ full screen, you can put your application embedded (parent) in a panel, and this panel fill the entire screen.

With my code first, you could put a text if you wish (BarraDeEstadomView.Text)



regards
 
Last edited:
Upvote 0

Binary01

Active Member
Licensed User
Longtime User
I got it.
I add a line in Manifest.

SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light.NoActionBar.TranslucentDecor")

Thanks bgsoft for your advice.

regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…