B
B
BorisSPb0072017-02-04 17:40:17
Mobile development
BorisSPb007, 2017-02-04 17:40:17

How to determine the real resolution of a smartphone?

Now I am redesigning the site for mobile devices and faced such a question.
Take the Asus Zen Phone. It claims a resolution of 1280×720.
Why, then, during development, phone 1280x720 correspond to 360x640? ()
The same data shows the "developer tools" in Google Chrome when moving to the development floor of mobile devices.
Why do you need to divide by 2 to find out the "real resolution" of a smartphone?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rou1997, 2017-02-04
@Rou1997

Apparently, you are confusing pixels and dpi, 1280x720 is the screen size in pixels, width by height, and 360x640 is dpi, how many pixels per inch of width or inch of screen height.
Add the diagonal (in inches) here, according to the Pythagorean theorem, everything should approximately converge.
For example, like this:

String res = "result=";
    
    try {
    DisplayMetrics metrics = new DisplayMetrics();
    acti.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    
    switch (metrics.densityDpi) {
    case DisplayMetrics.DENSITY_LOW:
      res += "ldpi";
      break;
    case DisplayMetrics.DENSITY_MEDIUM:
      res += "mdpi";
      break;
    case DisplayMetrics.DENSITY_HIGH:
      res += "hdpi";
      break;
    case DisplayMetrics.DENSITY_XHIGH:
      res += "xhdpi";
      break;
    case DisplayMetrics.DENSITY_XXHIGH:
      res += "xxhdpi";
      break;
    case DisplayMetrics.DENSITY_XXXHIGH:
      res += "xxxdpi";
      break;
    case DisplayMetrics.DENSITY_TV:
      res += "tv";
      break;
    default:
      res += "def" + metrics.densityDpi;
      break;
    }
    
    res += ", ";
    
    res += "dpi=[" + metrics.xdpi + "," + metrics.ydpi + "]";

    res += ", ";
    
    res += "pixels=[" + metrics.widthPixels + "," + metrics.heightPixels + "]";

    res += ", ";
    
    res += "scaledDensity=" + metrics.scaledDensity + "]";

    }
    catch (Exception ex) {
      Log.e("Analyticsutils", "Error1");
      ex.printStackTrace();
    }
    
    Log.i("Analyticsutils", res);

    if (showtoast) {
      try {
      Toast.makeText(acti, res, Toast.LENGTH_LONG).show();
      } catch (Exception ex) {
        Log.e("Analyticsutils", "Error2");
        ex.printStackTrace();
      }
    }

B
BorisSPb007, 2017-02-04
@BorisSPb007

Thanks for the detailed answer, but I probably disagree with your version.
I tried your version on my smartphone. Its width in inches is 7''. 7 * 360px = 1008px but not 720px

A
Ankhena, 2017-02-04
@Ankhena

viewportsizes.com are the viewport sizes of popular devices

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question