Can someone give me an example of how to get the center coordinates of the current displayed screen? I would like my objects to always be relative to the center coordinates of the active view.
DisplayMetrics
to achieve your solutionint mWidth= this.getResources().getDisplayMetrics().widthPixels;
int mHeight= this.getResources().getDisplayMetrics().heightPixels;
int cx =screenHeight = displaymetrics.heightPixels;
int cy = screenWidth = displaymetrics.widthPixels;
float finalRadius = (float) Math.sqrt(cx * cx + cy * cy);
float is the center if the object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With