Skip to content

Instantly share code, notes, and snippets.

@snadjafi
Created November 1, 2013 20:20
Show Gist options
  • Select an option

  • Save snadjafi/7271365 to your computer and use it in GitHub Desktop.

Select an option

Save snadjafi/7271365 to your computer and use it in GitHub Desktop.
dp to pix
public static int dipToPixels(Context context, float dip)
{
Resources r = context.getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics());
return (int) px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment