Last active
May 13, 2020 20:26
-
-
Save hector6872/478dfc55a6a4c9ac7a3ee974cf912cbe to your computer and use it in GitHub Desktop.
Android DpToPx converter
This file contains hidden or 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
int sizePx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, sizeDp, context.getResources().getDisplayMetrics()); |
This file contains hidden or 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
DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); | |
float sizePx = (sizeDp * displayMetrics.density); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment