Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created January 4, 2014 16:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominicthomas/8257203 to your computer and use it in GitHub Desktop.
Save dominicthomas/8257203 to your computer and use it in GitHub Desktop.
Get screen height excluding the action bar and notification bar.
public int getDisplayContentHeight() {
final WindowManager windowManager = getWindowManager();
final Point size = new Point();
int screenHeight = 0, actionBarHeight = 0;
if (getActionBar() != null) {
actionBarHeight = getActionBar().getHeight();
}
int contentTop = ((ViewGroup) findViewById(android.R.id.content)).getTop();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
windowManager.getDefaultDisplay().getSize(size);
screenHeight = size.y;
} else {
Display d = windowManager.getDefaultDisplay();
screenHeight = d.getHeight();
}
return screenHeight - contentTop - actionBarHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment