Android : How to determine if the Status Bar is translucent in Android >= Kitak?

on Friday, December 12, 2014


I have create a small library to place View beside / above or on top of existing ones, I use



MainView.getLocationOnScreen(..);


to determine the position of the Main View where the child object will be placed nearby.


Usually I'm determining the top (Y) of the Main View by the method above minus the height of the status bar using the following method:



protected boolean isTranslucentStaturBar()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = ((Activity) mainActionView.getContext()).getWindow();

--> return // SOME EXPRESSION TO DETERMINE IF THE STATUS BAR IS TRANSLUCENT <--- ?????
// I Need to know what expression I need to write here
}

return false;
}

protected int getStatusBarHeight() {
if (isTranslucentStaturBar()) {
return 0;
}

int result = 0;
int resourceId = mainActionView.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = mainActionView.getContext().getResources().getDimensionPixelSize(resourceId);
}
return result;
}


My problem is with Androids >= Kitkat, where you can actually set the status bar to translucent and window content spread to fill the place below the status bard icons..


0 comments:

Post a Comment