Created
November 13, 2018 10:28
-
-
Save hilfritz/1f6ec5833bae1a47106622fc598b0625 to your computer and use it in GitHub Desktop.
Android similar width/height in all device dimentions
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
//see https://stackoverflow.com/questions/37067271/android-graphics-drawing-same-size-circles | |
float devicePixelsWidth = fragment.getResources().getDisplayMetrics().widthPixels; | |
float deviceActualDpi = fragment.getResources().getDisplayMetrics().xdpi ; | |
float deviceActualInchWidth = devicePixelsWidth / deviceActualDpi ; | |
float deviceActualCMWidth = deviceActualInchWidth * 2.54f ; | |
float PixelsForActual3CM = devicePixelsWidth / deviceActualCMWidth * 3; | |
float radius = (float) (devicePixelsWidth / deviceActualCMWidth * 0.05); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment