get Screen Height - Android android.app

Android examples for android.app:Screen

Description

get Screen Height

Demo Code

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public class Main {


  public static int getScreenHeight(Context context) {
    DisplayMetrics metric = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metric);
    return metric.heightPixels;
  }/*from ww  w.j  a va  2 s. c  o  m*/

}

Related Tutorials