6 Lay Out a UI Using GUIDE
using the default figure Units of pixels does not produce a UI that looks the same on
all platforms.
For this reason, GUIDE defaults the Units property for the figure to characters.
System-Dependent Units
Character units are defined by characters from the default system font. The width
of a character unit equals the width of the letter x in the system font. The height of
a character unit is the distance between the baselines of two lines of text. Note that
character units are not square.
Units and Resize Behavior
If you set the resize behavior from the GUI Options dialog box, GUIDE automatically
sets the units for the UI components in a way that maintains the intended look and feel
across platforms. To specify the resize behavior option, select Tools > GUI Options, and
select an item from the Resize behavior pop-up menu:
- If you choose Non-resizable, GUIDE defaults the component units to characters.
- If you choose Proportional, GUIDE defaults the component units to normalized.
- If you choose Other (Use SizeChangedFcn), GUIDE defaults the component units
to characters. However, you must provide a SizeChangedFcn callback to customize
the resize behavior.
The Non-resizable and Proportional options enable your UI to automatically adjust
the size and relative spacing of components when the UI displays on different computers.
NoteGUIDE does not automatically adjust component units if you modify the figure's
Resize property programmatically or in the Property Inspector.
At times, it might be convenient to use a more familiar unit of measure, e.g., inches
or centimeters, when you are laying out the UI. However, to preserve the look of your
UI on different computers, remember to change the figure Units property back to
characters, and the components' Units properties to characters (nonresizable UIs)
or normalized (resizable UIs) before you save the UI.