Created
January 4, 2014 16:41
-
-
Save dominicthomas/8257203 to your computer and use it in GitHub Desktop.
Get screen height excluding the action bar and notification bar.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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