Advertisement
thieumao

Convert Dp to Px in Android

Feb 20th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. public static float cvDP2PX(float dp) {
  2. DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
  3. float px = dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
  4. return px;
  5. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement