Created
November 21, 2018 18:26
-
-
Save pavi2410/df6aad2e2eadeaf15d686e8a5da61e7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.*; | |
import android.view.*; | |
import android.util.*; | |
round(n) { | |
return Math.round(n*100.0)/100.0; | |
} | |
WindowManager wm = (WindowManager) ctx.getSystemService("window"); | |
dm = new DisplayMetrics(); | |
wm.defaultDisplay.getRealMetrics(dm); | |
w = dm.widthPixels; | |
h = dm.heightPixels; | |
print(w + "px x " + h + "px"); | |
xd = dm.xdpi; | |
yd = dm.ydpi; | |
print(round(xd) + "dpi x " + round(yd) + "dpi"); | |
x = w/xd; | |
y = h/yd; | |
print(round(x) + "\" x " + round(y) + "\""); | |
print(round(Math.sqrt(x*x + y*y)) + "\""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment