Skip to content

Instantly share code, notes, and snippets.

@emedinaa
Created October 4, 2013 03:10
Show Gist options
  • Save emedinaa/6820407 to your computer and use it in GitHub Desktop.
Save emedinaa/6820407 to your computer and use it in GitHub Desktop.
Convert dp to Pixel and px to DP
public static int dpToPx(int dp)
{
return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}
public static int pxToDp(int px)
{
return (int) (px / Resources.getSystem().getDisplayMetrics().density);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment