Example usage for android.util DisplayMetrics DENSITY_DEFAULT

List of usage examples for android.util DisplayMetrics DENSITY_DEFAULT

Introduction

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

Prototype

int DENSITY_DEFAULT

To view the source code for android.util DisplayMetrics DENSITY_DEFAULT.

Click Source Link

Document

The reference density used throughout the system.

Usage

From source file:com.chauthai.overscroll.BouncyAdapter.java

private double pxToDp(double px) {
    Resources resources = mContext.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    return px / ((double) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}

From source file:com.adherence.adherence.SwipeRevealLayout.java

private int pxToDp(int px) {
    Resources resources = getContext().getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    return (int) (px / ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT));
}

From source file:com.adherence.adherence.SwipeRevealLayout.java

private int dpToPx(int dp) {
    Resources resources = getContext().getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    return (int) (dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT));
}

From source file:com.android.argb.edhlc.Utils.java

public static float convertDpToPixel(float dp, Context context) {
    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    return dp * (metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

private static BitmapFactory.Options getScaledBitmapOptions() {
    if (bmpOptions == null) {
        bmpOptions = new BitmapFactory.Options();
        bmpOptions.inPurgeable = true;/*from w  ww .jav  a  2  s  .c  om*/
        bmpOptions.inInputShareable = true;
        bmpOptions.inDensity = DisplayMetrics.DENSITY_DEFAULT;
        bmpOptions.inTargetDensity = TiApplication.getAppDensityDpi();
        bmpOptions.inScaled = true;
    }
    return bmpOptions;
}

From source file:com.android.launcher3.Utilities.java

public static float dpiFromPx(int size, DisplayMetrics metrics) {
    float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
    return (size / densityRatio);
}

From source file:com.amaze.filemanager.activities.MainActivity.java

public int dpToPx(double dp) {
    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    int px = Math.round(Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)));
    return px;//from w  ww.j  ava2 s  . c  o m
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

public int dpToPx(double dp) {
    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    return Math.round(Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)));
}