Created
October 3, 2013 09:05
-
-
Save tatuas/6807282 to your computer and use it in GitHub Desktop.
dp pxの変換 for Android
Displayサイズの取得。
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
WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); | |
DisplayMetrics dm = new DisplayMetrics(); | |
wm.getDefaultDisplay().getMetrics(dm); | |
// dp -> px はこの値をdpの値にかければよい | |
dm.density; | |
// px -> dp はこの値でpxの値をわればよい | |
dm.density; | |
// dmはディスプレイの様々な情報を取得できる | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment