There is a picture (background) 480x800. I need to output a bitmap on top of the backgroader with certain coordinates. The problem is that on devices with a resolution of 480x800 is displayed correctly, and on others, respectively, with an offset. All pictures are in res / drawable directories. Later I plan to make all the pictures of different sizes and scatter them in their directories (hdpi, ldpi, etc.)
Screen sizes and other variables I get the following code (in the comments of their values):
Here I took the emulator 480x800:
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); frameWidth = metrics.widthPixels; // 480 frameHeight = metrics.heightPixels; // 800 xDpi = metrics.xdpi; // 240 yDpi = metrics.ydpi; // 240 scaleFactor = getResources().getDisplayMetrics().density; // 1.5 Here I took 720x1280:
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); frameWidth = metrics.widthPixels; // 720 frameHeight = metrics.heightPixels; // 1232 xDpi = metrics.xdpi; // 164.75676 yDpi = metrics.ydpi; // 165.03554 scaleFactor = getResources().getDisplayMetrics().density; // 1.0 What is the principle to calculate the output coordinates so that the sprites / bitmaps are displayed the same way on all devices relative to the background / other objects / each other?

