Sets the width and height for the UI element.
Your app sometimes needs to resize UI elements on a screen. All UI elements (button()
, textInput()
, textLabel()
, dropDown()
, checkBox()
, radioButton()
, image()
), can be resized. It is usually easier to place UI elements in their initial positions, with initial sizes, using Design mode in App Lab. In Design mode you can also specify font size, font color and background color for UI elements.
// Three sizes. image("idSmall", "https://code.org/images/logo.png"); setSize("idSmall", 50, 50); image("idMedium", "https://code.org/images/logo.png"); image("idLarge", "https://code.org/images/logo.png"); setSize("idLarge", 200, 200);
setSize(id, width, height)
Name | Type | Required? | Description |
---|---|---|---|
id | string | The ID of the UI element to which this event handler applies. Must begin with a letter, contain no spaces, and may contain letters, digits, - and _. | |
height | number | The height to set the UI element to, in pixels. | |
width | number | The width to set the UI element to, in pixels. |
Found a bug in the documentation? Let us know at documentation@code.org