List of utility methods to do Display Density Get
float | getDensity(Context context) get Density return context.getResources().getDisplayMetrics().density;
|
int | getDensitySize(Context context, int size) get Density Size return (int) getDensity(context) * size; |
Rect | getBounds(Display d, Rect r) get Bounds return new Rect(r.left, r.top, d.getWidth() - r.right, d.getHeight() - r.bottom); |
float | applyDimension(int unit, float value, DisplayMetrics metrics) apply Dimension switch (unit) { case TypedValue.COMPLEX_UNIT_PX: return value; case TypedValue.COMPLEX_UNIT_DIP: return value * metrics.density; case TypedValue.COMPLEX_UNIT_SP: return value * metrics.scaledDensity; case TypedValue.COMPLEX_UNIT_PT: ... |
float | getDisplayPPI() device methods DisplayMetrics displayMetrics = Resources.getSystem()
.getDisplayMetrics();
return (displayMetrics.xdpi + displayMetrics.ydpi) / 2.0f;
|