- Home /
How do i make my ui elements stay the same size and position on all andorid devices?
Im making an app for android in unity and in my main menu i have 3 ui buttons and the title image. I test my app by exporting the apk onto my phone instead of using an emulator or the remote. My problem is though the ui buttons and image shrink in size and move closer to the center of the screen but they remain in the same relative position to eachother.
here is what it looks like on my PC. How do i make it so that it looks like this on almost every android device?
Change the anchor positions. I believe putting one anchor in each corresponding corner should work.
@Namey5 Thanks so much for your answer, can you explain a little bit more?
This is a very old question, and I also didn't fully have a grasp of all UGUI features. The correct way to handle responsive UI is to change your canvas scaling mode to scale with screen resolution. From there you can set a reference resolution (i.e. the resolution the UI was designed for) and everything else will scale accordingly. I would recommend using the 'Expand' scaling mode as it will make sure all UI elements fit on screen no matter the aspect ratio.
Answer by Thom Denick · Jan 02, 2015 at 12:56 AM
Namey & gjf hit it, but basically there are several ways to do this in the new Unity UI.
If you move your Canvas to World Space, your UI will render the same no matter the resolution. If you are concerned about pixel perfect GUIs, this is not a desirable option as you need to have high-res assets to look good on all devices. Find this setting on the main Canvas script.
If you want the items to stay pixel perfect for clean edges, then Canvas Scaler is probably what you want. This is on the default Canvas object. Change the UI Scale Mode to a desirable pixels per unit.
As an alternative to World Space (this might be less confusing depending on how your GUI works), you can use anchoring positions as Namey suggests.
Thank you very much! you helped me as well. (even if it was a long time ago :) )
Do you have any more info on 3? We can't switch our canvas to world pos, and there's little info on actually handling dynamic (responsive) scaling.
Your answer
Follow this Question
Related Questions
Use different sprites in new Unity UI for SD vs HD 2 Answers
Scaling resolution for Mobile devices using UI elements 1 Answer
OnDrag OnPointerDown OnPointerUp does not work 1 Answer
Draw a line from finger game for mobile 0 Answers
UI image with button component not tracking mouse correctly 1 Answer