Example usage for android.util DisplayMetrics DisplayMetrics

List of usage examples for android.util DisplayMetrics DisplayMetrics

Introduction

In this page you can find the example usage for android.util DisplayMetrics DisplayMetrics.

Prototype

public DisplayMetrics() 

Source Link

Usage

From source file:Main.java

public static int getScreenHeight(Activity activity) {
    DisplayMetrics metric = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metric);
    return metric.heightPixels;
}

From source file:Main.java

public static int getHeightPixels(Activity activity) {
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm.heightPixels;
}

From source file:Main.java

public static int getScreenWidth(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    dm = context.getResources().getDisplayMetrics();
    return dm.widthPixels;
}

From source file:Main.java

public static int getWindowWidth(Activity activity) {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return metrics.widthPixels;
}

From source file:Main.java

public static int getWindowHeight(Activity activity) {
    DisplayMetrics metric = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metric);
    return metric.heightPixels;
}

From source file:Main.java

public static int getScreenWidth(Activity mActivity) {
    DisplayMetrics dm = new DisplayMetrics();
    mActivity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm.widthPixels;
}

From source file:Main.java

public static int getWindowHeight(Activity activity) {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return metrics.heightPixels;
}

From source file:Main.java

public static int getScreenHeight(Activity activity) {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return metrics.heightPixels;
}

From source file:Main.java

public static int getHeightPixels(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    dm = context.getResources().getDisplayMetrics();
    return dm.heightPixels;
}

From source file:Main.java

public static int sp2px(Context cx, float spValue) {
    DisplayMetrics dm = new DisplayMetrics();
    dm = cx.getApplicationContext().getResources().getDisplayMetrics();
    return (int) (spValue * dm.scaledDensity + 0.5f);
}