UI is not aligned properly

Hello everyone.
I’m enabling both fit-width and fit-height in the game and the background image is larger to avoid black spaces. I have added a test button element, (see the editor image below)editor
but when I run, the button alignment is changed(see the images below)


ipad1
This happens because the canvas doesn’t fit the entire screen, but is there a way to place the UI elements properly without changing its alignment? or fit the canvas to entire screen?
cocos creator version: 2.4.4
demo project link: GitHub - maheshnnaik/cocos-creator-test
Thank you

I can ask engineering to have a look at this topic.

@maheshn, You can achieve that using the widget class

I have enabled widget for button, is 60px from top and right. I have enabled both fit-width and fit-height for canvas, I have shared the demo project link above.
Thank you

@maheshn, I guess you are right. It only positions relative to canvas design resolution when both fit-width and fit-height are enabled.
You may need to code repositioning of the UI based on the view size after resize.
Alternative would be to switch between fit-width and fit-height during resize based on the resolution which can be a little annoying to achieve.

Yes I did the same referring Tutorial: Cocos Creator: Improving multi-device adaptation. This is working fine now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.