Constraints
Constraints define how widgets respond when the screen size changes.
They ensure your layout stays consistent across different devices and orientations β whether it's a phone, tablet, or desktop screen.
You can apply constraints on both the horizontal and vertical axes to control alignment and resizing behavior.
Horizontal Constraintsβ
Horizontal constraints determine how a widget behaves along the X-axis.
- Left β Keeps the widget fixed relative to the left side of the screen.
- Right β Keeps the widget fixed relative to the right side of the screen.
- Left and Right β Anchors the widget to both sides, causing it to resize horizontally as the screen width changes.
Vertical Constraintsβ
Vertical constraints determine how a widget behaves along the Y-axis.
- Top β Keeps the widget fixed relative to the top of the screen.
- Bottom β Keeps the widget fixed relative to the bottom of the screen.
- Top and Bottom β Anchors the widget to both sides, causing it to resize vertically as the screen height changes.