Skip to content

Instantly share code, notes, and snippets.

@shau-lok
Last active April 18, 2016 02:54
Show Gist options
  • Save shau-lok/0ffce303b47b264ccdf80e6da150a5cd to your computer and use it in GitHub Desktop.
Save shau-lok/0ffce303b47b264ccdf80e6da150a5cd to your computer and use it in GitHub Desktop.
像素转换,using density
int width = 72;
int height = 96;
float scale = getResources().getDisplayMetrics().density;
int pixelsWidth = (int) (width * scale + 0.5f);
int pixelsHeight = (int) (height * scale + 0.5f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment