Few Android devices have bottom software navigation bars which include back & home buttons. In this article, I am going to share a utility method to get full screen size including top status bar & bottom navigation bar in Android in both Java & Kotlin.
If you want to get screen size without including the top status bar and bottom navigation bar, then visit the following tutorial.
Utility Class to Get Screen Width & Height in Kotlin Android

Get Full Screen Size in Java
You can use the following method to get the screen width and height in JAVA. It takes Context as a parameter and returns an integer array. In the returned array index 0 contains the width and index 1 contains the height of the screen.
/// Get Screen width & height including top & bottom navigation bar
public static int[] getScreenSizeInlcudingTopBottomBar(Context context) {
int [] screenDimensions = new int[2]; // width[0], height[1]
int x, y, orientation = context.getResources().getConfiguration().orientation;
WindowManager wm = ((WindowManager)
context.getSystemService(Context.WINDOW_SERVICE));
Display display = wm.getDefaultDisplay();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
Point screenSize = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(screenSize);
x = screenSize.x;
y = screenSize.y;
} else {
display.getSize(screenSize);
x = screenSize.x;
y = screenSize.y;
}
} else {
x = display.getWidth();
y = display.getHeight();
}
screenDimensions[0] = orientation == Configuration.ORIENTATION_PORTRAIT ? x : y; // width
screenDimensions[1] = orientation == Configuration.ORIENTATION_PORTRAIT ? y : x; // height
return screenDimensions;
}
Get Full Screen Size in Kotlin
In Kotlin, use the following method to get the screen width and height, It takes Context as a parameter and returns an integer array. Same as above, the returned array’s index 0 contains the width and index 1 contains the height of the screen.
/// Get Screen width & height including top & bottom navigation bar
fun getScreenSizeInlcudingTopBottomBar(context: Context): IntArray {
val screenDimensions = IntArray(2) // width[0], height[1]
val x: Int
val y: Int
val orientation = context.resources.configuration.orientation
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val display = wm.defaultDisplay
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
val screenSize = Point()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(screenSize)
x = screenSize.x
y = screenSize.y
} else {
display.getSize(screenSize)
x = screenSize.x
y = screenSize.y
}
} else {
x = display.width
y = display.height
}
screenDimensions[0] = if (orientation == Configuration.ORIENTATION_PORTRAIT) x else y // width
screenDimensions[1] = if (orientation == Configuration.ORIENTATION_PORTRAIT) y else x // height
return screenDimensions
}
That’s it. This is how to get full-screen size including the software navigation bar and top status bar in Android. Both of the above methods use WindowManager & DisplayMetrics interfaces to get the screen dimensions.
If you have any questions, feel free to ask in the comments section below.