SHARE
TWEET

Android get screen density name (bucket)

ulfben Jan 25th, 2017 137 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //https://developer.android.com/about/dashboards/index.html#Screens
  2. private static String getDensityName(DisplayMetrics dm) {
  3.         float density = dm.density;
  4.         if (density >= 4.0) {
  5.             return "xxxhigh density";
  6.         }
  7.         if (density >= 3.0) {
  8.             return "xxhigh density";
  9.         }
  10.         if (density >= 2.0) {
  11.             return "xhigh density";
  12.         }
  13.         if (density >= 1.5) {
  14.             return "high density";
  15.         }
  16.         if (density >= 1.0) {
  17.             return "medium density";
  18.         }
  19.         return "low density";
  20.     }
RAW Paste Data
Top