I am trying to figure out how I can tell the location of the status bar (top or bottom). I tried to inspect HierarchyViewer
but didn't see the status bar view.
Really what I need to figure out is, given a context, a way to return a boolean
(true if bar is on top, false if it isn't -- like it isn't on most tablets). I wrote a simple solution to try and figure out of the status bar is at the top or bottom, but it doesn't seem to be helping:
private boolean isStatusBarAtTop(){
if (!(getContext() instanceof Activity)) {
return !getContext().getResources().getBoolean(R.bool.isTablet);
}
Window window = ((Activity) getContext()).getWindow();
if(window == null) {
return !getContext().getResources().getBoolean(R.bool.isTablet);
}
Activity activity = (Activity)getContext();
Rect rect = new Rect();
window.getDecorView().getWindowVisibleDisplayFrame(rect);
View ourView = window.findViewById(Window.ID_ANDROID_CONTENT);
Log.d("Menu","Window Top: "+ ourView.getTop() + ", "+ourView.getBottom()+ ", "+ourView.getLeft()+", "+ourView.getRight());
Log.d("Menu","Decor View Dimensions"+rect.flattenToString());
return ourView.getTop() != 0;
}
And for some reason I get the following as output (running on Nexus 7 Tablet):
D/Menu(1007): Window Top: 0, 0, 0, 0
D/Menu(1007): Decor View Dimensions0 0 800 1216
What am I thinking/doing wrong?