coder_For_Life22
coder_For_Life22

Reputation: 26971

How to get height of Screen?

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

Answers (2)

Julian
Julian

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

Timothy Miller
Timothy Miller

Reputation: 291

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();

Height would be in the height variable.

Upvotes: 3

Related Questions