Margin

The margin of a field is the area that is outside of the field's border. You cannot paint in the margin of a field. Margins are used to control the space between fields in a manager, and it is the responsibility of the manager to respect margins correctly.

When two fields that have margins are positioned next to each other on a screen, the margins collapse into each other. For example, consider two fields that both have margins of five pixels. If these fields are placed next to each other on a screen, you might expect that the space between them would be 10 pixels (five pixels for each field). Instead, the space between them is only five pixels, because the margins collapse by five pixels.

When two fields that have unequal margins are positioned next to each other, the margins collapse by the smaller of the two margins. For example, consider a field with a margin of four pixels and a field with a margin of eight pixels. If these fields are placed next to each other, the space between them is eight pixels.

Previous topic: Border

Was this information helpful? Send us your comments.