I found java code here for getting the height of ToolBar and StatusBar. I should note that I am not a Java expert.
The function for geting the StatusBar height works.
In the function for geting the height of the TitleBar, I don't know what to put in the RunMethod function parameter, which is represented in the Java function by "BA ba"
Java:
#If JAVA
import android.view.Window;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
public int StatusBarHeight(){
int result = 0;
int resId = BA.applicationContext.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resId > 0) {
result = BA.applicationContext.getResources().getDimensionPixelSize(resId);
}
return result;
}
public int TitleBarHeight(BA ba) {
int viewTop = ba.activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
return (viewTop - StatusBarHeight());
}
#End If
B4X:
Private nativeMe As JavaObject
...
nativeMe = Me
Sub StatusBarHeight As Int
Dim id As Int = nativeMe.RunMethod("StatusBarHeight", Null)
Return id
End Sub
B4X:
Sub TitleBarHeight As Int
Dim id As Int = nativeMe.RunMethod("TitleBarHeight", ???) - witch parameter
Return id
End Sub
Last edited: