Android Relative Screen Size / Aspect?

I almost finished my game for android and while developing it I always tested it on my phone that has a 1920x1080 pixels screen and it worked perfectly. Now that it is almost done I tested it on another phone that only has a 1280x720 pixels screen and you can only see a section of the game (a part that would normally be in the middle of the screen). I know that you can change the aspect in unity (it is currently set to 1920x1080 for me) and I also know that you can make a canvas relative or absolute. But if I change the screen size / aspect from my current setting to 16:9 all the buttons are somewhere else in relation to the screen than they were before. Is there a way to fix this problem without having to move every button, camera etc. individually to the position I want it to be? (and so that they are at the same position on every phone regardless of the amount of pixels the screen has)

The short answer is, no, there are always some problems with screen sizes and aspect ratios. Unless you want things to scale up and down, possibly including stretched text/icons (which is generally not recommended at all), there’s not much you can do about that. Some minor text and icon stretching is usually acceptable, but you might not want to rely on it, since there are way too many different aspect ratios and resolutions. Instead, the best you can do is hope your user has a pretty normal-looking screen, and

  1. Play around with the Canvas and Aspect Ratio Fitter settings.
  2. 9-slice your buttons and other UI elements so that they don’t look too stretched, even if they are.
  3. Anchor your UI elements correctly. If you have a dialog with an “OK” button on the bottom left and a “Cancel” button on the bottom right, then anchor your “OK” button to the bottom left of the container and the “Cancel” button to the bottom right of the container.
  4. Concerning the previous point, you may also want to move their pivots to the bottom left and bottom right, respectively, depending on your intentions. If you’re not messing with their rotations, you can probably go ahead and do that.

Those last two are probably most important for keeping your buttons in the right places. Since the screen will resize, it won’t be in exactly the same place, but something that’s supposed to be at the top will still be at the top, and something that’s in the corner will still be in the same corner. The general idea is to keep pixel offsets to a minimum, so changes in pixel count won’t significantly affect the appearance.