Align UI components and graphics objects
Use this function only with GUIDE, or with apps created
using the figure
function.
align(HandleList,'HorizontalAlignment','VerticalAlignment')
Positions = align(HandleList, 'HorizontalAlignment',
'VerticalAlignment')
Positions = align(CurPositions, 'HorizontalAlignment',
'VerticalAlignment')
align(HandleList,'HorizontalAlignment','VerticalAlignment')
aligns the uicontrol
and axes
objects in
HandleList
, a vector of handles, according to the options
HorizontalAlignment
and
VerticalAlignment
. The following tables show the possible
values for HorizontalAlignment
and
VerticalAlignment
.
| Definition |
---|---|
| No horizontal alignment |
| Aligns the left edges of the objects with the left edge of the bounding box that encloses the objects |
| Shifts objects to center their positions to the average of the extreme x-values of the group |
| Aligns the right edges of the objects with the right edge of the bounding box that encloses the objects |
| Equalizes x-distances between all objects within the span of the extreme x-values |
| Spaces objects to have a specified number of points between them in the x-direction |
| Definition |
---|---|
| No vertical alignment |
| Aligns the top edges of the objects with the top edge of the bounding box that encloses the objects |
| Shifts objects to center their positions to the average of the extreme y-values of the group |
| Aligns the bottom edges of the objects with the bottom edge of the bounding box that encloses the objects |
| Equalizes y-distances between all objects within the span of the extreme y-values |
| Spaces objects to have a specified number of points between them in the y-direction |
Aligning objects does not change their absolute sizes. All alignment options align
the objects within the bounding box that encloses the objects.
Distribute
and Fixed
align objects to
the bottom left of the bounding box. Distribute
evenly
distributes the objects while Fixed
distributes the objects
with a fixed distance (in points) between them. When you specify both horizontal
and vertical distance together, the keywords
'HorizontalAlignment'
and
'VerticalAlignment'
are not necessary.
If you use Fixed
for HorizontalAlignment
or
VerticalAlignment
, you must also specify the distance, in
points, where 72 points equals 1 inch. For example:
align(HandleList,'Fixed',Distance,'VerticalAlignment')
distributes the specified components Distance
points
horizontally and aligns them vertically as specified.
align(HandleList,'HorizontalAlignment','Fixed',Distance)
aligns the specified components horizontally as specified and distributes them
Distance
points vertically.
align(HandleList,'Fixed',HorizontalDistance,... 'Fixed',VerticalDistance)
distributes the specified components HorizontalDistance
points
horizontally and distributes them VerticalDistance
points
vertically.
Positions = align(HandleList, 'HorizontalAlignment',
'VerticalAlignment')
returns updated positions for the specified objects as a vector of
Position
vectors. The position of the objects on the
figure does not change.
Positions = align(CurPositions, 'HorizontalAlignment',
'VerticalAlignment')
returns updated positions for the objects whose positions are contained in
CurPositions
, where CurPositions
is a
vector of Position
vectors. The position of the objects on
the figure does not change.