Skip to content

Instantly share code, notes, and snippets.

@mahdi-malv
Created November 10, 2018 08:19
Show Gist options
  • Save mahdi-malv/8e8afe869717cafce643002356d7df55 to your computer and use it in GitHub Desktop.
Save mahdi-malv/8e8afe869717cafce643002356d7df55 to your computer and use it in GitHub Desktop.
change dp or sp to px in android
public static float dpOrSpToPx(final Context context, final float dpOrSpValue) {
return dpOrSpValue * context.getResources().getDisplayMetrics().density;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment