Android Question How to Toggle the NavigationBar On and Off at Runtime with B4XPages and AppCompat?

ykucuk

Well-Known Member
Licensed User
Longtime User
Hi everyone,

I'm currently using B4XPages and axrlottie, which requires me to use appcompat. While I am using
B4X:
#IncludeTitle: false
to hide the title bar, I am unable to hide the NavigationBar on the MainPage.

Could someone please guide me on how to dynamically show and hide the NavigationBar during runtime? Any help or code examples would be greatly appreciated.

Thank you!
 

Attachments

  • bfc4c39a-0f54-41b6-ad5d-2c2e8daab53f.jpeg
    bfc4c39a-0f54-41b6-ad5d-2c2e8daab53f.jpeg
    53.6 KB · Views: 82
  • c5606c40-c0c8-4967-9b9d-5521bbf0fc8f.jpeg
    c5606c40-c0c8-4967-9b9d-5521bbf0fc8f.jpeg
    43.6 KB · Views: 80

ykucuk

Well-Known Member
Licensed User
Longtime User
B4X:
Private Sub SetActionBarState(Visible As Boolean)
    Dim jo As JavaObject
    jo.InitializeContext
    jo.RunMethodJO("getSupportActionBar", Null).RunMethod(IIf(Visible, "show", "hide"), Null) 'change to "getActionBar" for non-AppCompat
End Sub
Hello Erel,

The code you provided works correctly, but there's an issue. When I close the bar, a section remains empty below, equal to the height of the bar. It does not fit 100%. The root screen does not cover the entire display. I have attached a screenshot. How can I prevent this?
 

Attachments

  • Screenshot 2024-08-07 at 11.46.46 AM.png
    Screenshot 2024-08-07 at 11.46.46 AM.png
    253.7 KB · Views: 79
Upvote 0
Top