How to make MapView height take the Android status bar into account?
I have clickable icons on a map showing a PopupWindow just above the icon when clicked. However, if the icon is on the topmost part of the map the PopupWindow will be hidden under the An开发者_Python百科droid Status Bar. The PopupWindow will automatically adjust to the right and left edges of the screen, and also to the top edge but doesn't take the status bar panel into account.
Either there should be a way to accomodate the height of the MapView, or an attribute to the PopupWindow that takes the status bar into account. Of course it's always possible to add a fixed size top margin, but the top panel have different heights on different Android units.
Can anyone help with this? Thanks!
I still haven't found a way to adjust the MapView hieght to the Android status bar wich is unfortunate.
However in the case of the PopupWindow it is sufficient to know the height of the Android status bar since it is placed on the screen by the coder. The coder can then make her own strategy around the issue.
According to the other post, this is how it can be done:
Rect rectgle = new Rect();
Window window = getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
statusBarHeight = rectgle.top;
However, take care not to do this calculation until all window components have been initialized since it will otherwise be zero. That is easily noticed and mended.
BR, Vanja
精彩评论