Android Question Need to get info about status bar and nav bar?

alexwekell

Member
Licensed User
I have an app with toggles for turning translucent bars on and off, but for it to properly work it needs to have an offset value in dip units and know if the users device has software buttons. What is the best way to get to get the height of the status bar and navbar in dip units and detect if the user has software keys (if there is a navbar)?
 

Erel

Administrator
Staff member
Licensed User
You can use this code to check whether the navigation bar exists:
B4X:
Sub NavigationBarExists As Boolean
   Dim jo As JavaObject
   jo.InitializeStatic("android.view.KeyCharacterMap")
   Dim hasBackKey As Boolean = jo.RunMethod("deviceHasKey", Array (KeyCodes.KEYCODE_BACK))
   Dim hasHomeKey As Boolean = jo.RunMethod("deviceHasKey", Array (KeyCodes.KEYCODE_HOME))
   Return Not(hasBackKey AND hasHomeKey)
End Sub
Based on this post: http://stackoverflow.com/questions/16092431/check-for-navigation-bar

You can compare 100%y to GetDeviveDisplayLayout.Height to find the height of all bars combined.
 
Upvote 0

alexwekell

Member
Licensed User
You can use this code to check whether the navigation bar exists:
B4X:
Sub NavigationBarExists As Boolean
   Dim jo As JavaObject
   jo.InitializeStatic("android.view.KeyCharacterMap")
   Dim hasBackKey As Boolean = jo.RunMethod("deviceHasKey", Array (KeyCodes.KEYCODE_BACK))
   Dim hasHomeKey As Boolean = jo.RunMethod("deviceHasKey", Array (KeyCodes.KEYCODE_HOME))
   Return Not(hasBackKey AND hasHomeKey)
End Sub
Based on this post: http://stackoverflow.com/questions/16092431/check-for-navigation-bar

You can compare 100%y to GetDeviveDisplayLayout.Height to find the height of all bars combined.

What is GetDeviveDisplayLayout.Height?
 
Upvote 0
Top