Created
September 19, 2018 12:30
-
-
Save imandaliya/f3e2175bd60dfd9a7b9ed967e2f869f2 to your computer and use it in GitHub Desktop.
This file contains 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
// get Width and height of the screen | |
// this method only give available space for application screen | |
DisplayMetrics displayMetrics = new DisplayMetrics(); | |
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); | |
int height = displayMetrics.heightPixels; | |
int width = displayMetrics.widthPixels; | |
// get real height and width of the device | |
WindowManager windowManager = | |
(WindowManager) BaseApplication.getApplication().getSystemService(Context.WINDOW_SERVICE); | |
final Display display = windowManager.getDefaultDisplay(); | |
Point outPoint = new Point(); | |
if (Build.VERSION.SDK_INT >= 19) { | |
// include navigation bar | |
display.getRealSize(outPoint); | |
} else { | |
// exclude navigation bar | |
display.getSize(outPoint); | |
} | |
if (outPoint.y > outPoint.x) { | |
mRealSizeHeight = outPoint.y; | |
mRealSizeWidth = outPoint.x; | |
} else { | |
mRealSizeHeight = outPoint.x; | |
mRealSizeWidth = outPoint.y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment