[ad_1]
I can not off code itself however i can supply the speculation behind it with some pseudo code
First of all some principle:
Screens have a decision that is mesured in pixels so for instance, 1920*1080
on a display of 10 inches, that is extra pixels per inch so 20 pixels on this display would take up much less house then 20 pixels on a 40inch display, due to this some math earlier than the sport begins is required.
int width = getScreenWidth();
int top = getScreenHeight();
int dispWidth = getDeviceWidth();
int dispHeight = getDeviceWidth();
int PPI = caclulate the PPI with algorithm
You would then want to vary some code to work out the pixels wanted to repair say 1/2 inch diameter circle. which might be straightforward sufficient.
Another option to do it’s trying on the Developer Documentation https://developer.android.com/reference/android/util/DisplayMetrics.html
it lists the dimensions of the screens on completely different densities after which set variables based on that, It’s been a number of years since I’ve accomplished any work with android however i imagine you can even set pixel density on a canvas too.
[ad_2]