Skip to content

Margins

The Margins class defines the space around a view or element. It specifies the margin values for the left, top, right, and bottom sides.

Constructor:

  • constructor(left: number | string, top: number | string, right: number | string, bottom: number | string)
    Left, top right and bottom values should be in the form: 25/'10ch'/'25%' (ch - character width. % - percentage of the parent width/height)
Example
this.view.margins = new Margins(10, 20, 10, 20);  
this.view.margins = 5;         // all margins are 5  
this.view.margins = '1ch';     // all margins are 1 char width/height  
this.view.margins.left = 5;    // left margin is 5