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 getDisplayDensity(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    dm = context.getResources().getDisplayMetrics();
    return dm.densityDpi;
}

From source file:Main.java

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

From source file:Main.java

public static float getScreenensity(Activity context) {
    DisplayMetrics metric = new DisplayMetrics();
    context.getWindowManager().getDefaultDisplay().getMetrics(metric);
    float density = metric.density;
    return density;
}

From source file:Main.java

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

From source file:Main.java

public static int getScreenHeight(Activity mActivity) {

    DisplayMetrics metric = new DisplayMetrics();
    mActivity.getWindowManager().getDefaultDisplay().getMetrics(metric);

    return metric.heightPixels;
}

From source file:Main.java

public static int getScreenDensity(Activity context) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    context.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    return displayMetrics.densityDpi;
}

From source file:Main.java

public static int[] getScreenWidth(Activity context) {
    DisplayMetrics displayMetrics = new DisplayMetrics();
    context.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    return new int[] { displayMetrics.widthPixels, displayMetrics.heightPixels };
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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