| MATLAB® | ![]() |
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 table shows the possible values for HorizontalAlignment and VerticalAlignment.
HorizontalAlignment | Definition |
|---|---|
None | No horizontal alignment is made |
Left | Shifts the objects' left edges to that of the first object selected |
Center | Shifts objects to center their positions to the average of the extreme x-values of the group |
Right | Shifts the objects' right edges to that of the first object selected |
Distribute | Equalizes x-distances between all objects within the span of the extreme x-values |
Fixed | Spaces objects to have a specified number of points between them in the y-direction |
VerticalAlignment | Definition |
|---|---|
None | No vertical alignment is made |
Top | Shifts the objects' top edges to that of the first object selected |
Middle | Shifts objects to center their positions to the average of the extreme y-values of the group |
Bottom | Shifts the objects' bottom edges to that of the first object selected |
Distribute | Equalizes y-distances between all objects within the span of the extreme y-values |
Fixed | Spaces objects to have a specified number of points between them in the x-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 Horizontal Alignment or Vertical Alignment, then you must specify the distance, in points, as an extra argument. These are some examples:
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.
Note 72 points equals 1 inch. |
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.
Create a GUI with three buttons and use align to line up the buttons.
Create a figure window and one button object.
f=figure;
u1 = uicontrol('Style','push', 'parent', f,'pos',...
[20 100 100 100],'string','button1');

Create two more button objects, not aligned with each other or any part of the figure window.
u2 = uicontrol('Style','push', 'parent', f,'pos',...
[150 250 100 100],'string','button2');
u3 = uicontrol('Style','push', 'parent', f,'pos',...
[250 100 100 100],'string','button3');

Align the button objects with the bottom of the first button object, equalizing the distance between the objects within the span of the extreme x-values.
align([u1 u2 u3],'distribute','bottom');

![]() | airy | alim | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |