Created
September 5, 2017 14:45
-
-
Save JonathandelaSen/6c6131ffa691dabbb9a000a647c3d270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DpsPxsConversion { | |
public static float dpFromPx(final Context context, float px) { | |
return px / context.getResources().getDisplayMetrics().density; | |
} | |
public static float pxFromDp(final Context context, float dp) { | |
return dp * context.getResources().getDisplayMetrics().density; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment