Get Screen Size Pixels per Inch Android example

The exact physical pixels per inch of the screen
Get size of pixel
Get DPI
Get count of pixels per inch

        float mXDpi;
        float mYDpi;
           DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            mXDpi = metrics.xdpi; // The exact physical pixels per inch of the screen in the X dimension. 
            mYDpi = metrics.ydpi;
          float  mMetersToPixelsX = mXDpi / 0.0254f; // 1 inch == 0.0254 metre
          float  mMetersToPixelsY = mYDpi / 0.0254f;
This entry was posted in Android Examples Code, Bitmap, drawing and tagged , . Bookmark the permalink.


Comments are closed.



8,870 views