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 getScreenW(Context aty) {
    DisplayMetrics dm = new DisplayMetrics();
    dm = aty.getResources().getDisplayMetrics();
    int w = dm.widthPixels;
    // int w = aty.getWindowManager().getDefaultDisplay().getWidth();
    return w;//from   w  ww  . ja  va 2s . c om
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static float getDeviceWidth(Context cx) {
    DisplayMetrics dm = new DisplayMetrics();
    dm = cx.getApplicationContext().getResources().getDisplayMetrics();
    return dm.widthPixels;
}

From source file:Main.java

public static int GET_SCREEN_HEIGHT(Activity a) {
    DisplayMetrics dm = new DisplayMetrics();

    a.getWindowManager().getDefaultDisplay().getMetrics(dm);

    return dm.heightPixels;
}

From source file:Main.java

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

From source file:Main.java

public static int[] getScreenSize(Activity activity) {
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return new int[] { dm.widthPixels, dm.heightPixels };
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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