- Home /
How can a child element of Vertical Layout Group fit its Parent in Unity?
I am making an app that is optimized for all screen sizes (basically for Android) in Unity. For that purpose, I am using Vertical Layout Group so that elements are placed properly in Stack Layout and don't overlap in different Screen Resolutions.
I have Parent Element that is stretched throughout the screen setting Anchor Stretch to Top = Bottom = Left = Right = 0. The Parent has a Vertical Layout Group Component. Then I have a Child element. I need to stretch it to fit its parent ie. stretch throughout the Screen. I have set my Game Resolution to 480x800. Now when I Increase the resolution to suppose 1920x1080, the Child Image shrinks its size. I want it to fit its parent that is stretched throughout the screen width & height.
Here are the Screenshots for reference.
At 480x800 Resolution (Parent Element)
At 480x800 Resolution (Child Element)
At 1920x1080 Resolution (Child Element) Here the problem arises when the resolution increases. I want the Child Element to be stretched and must fit its Parent.
Answer by exploringunity · Jul 23, 2020 at 08:40 PM
Hey @junedmmn ,
Have you tried toggling the Control Child Size (Width and Height) checkboxes on the Vertical Layout Group component? Check out the AutoLayout docs for more info. Hope this helps!
Your answer
Follow this Question
Related Questions
How to change the height of a button according to the height of the text in it? 2 Answers
Preserving aspect ratio for layout group elements 3 Answers
Need some help regarding UI layout in different Screen resolutions 1 Answer
Best way to move elements around screen [uGUI] 0 Answers
UI Texture Max Size (inspector) 1 Answer