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 boolean isTablet(Activity activity) {
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    double diagonalPixels = Math.sqrt(Math.pow(dm.widthPixels, 2) + Math.pow(dm.heightPixels, 2));
    double physicalSize = diagonalPixels / (160 * dm.density);
    return physicalSize > 7;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static float getFontScale(Context context) {
    DisplayMetrics dm = new DisplayMetrics();
    dm = context.getResources().getDisplayMetrics();
    return dm.density;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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