Reputation: 26971
I am trying to get the Height of the device screen that the application is running on.
How would i go about getting just the Height only?
Upvotes: 0
Views: 2149
Reputation: 2101
Take a look at the DisplayMetrics class: https://developer.android.com/reference/android/util/DisplayMetrics.html#heightPixels
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
Upvotes: 2
Reputation: 291
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Height would be in the height variable.
Upvotes: 3