Setting and Querying NativeUI Object Attributes
The NativeUI objects have attributes associated with them. For example, an object might have a Width attribute or a Height attribute.
You can set attribute values in two ways:
You can initially set an attribute value for an object by passing the value as part of the object’s constructor when creating the object.
After the object is created, you can change the value using a setter, for example
setWidth().
Note: | You cannot change attribute values that are set in the constructor unless there is a corresponding setter for the attribute. |
In addition to setting attribute values, once an attribute is created, you can query its value using a getter, for example getWidth().
Note: | You might have to wait until the element is drawn on the screen before getting platform-level display metrics, such as the object’s width, height, and X/Y coordinates. For example, some platform widgets might return misleading values for their height, such as 0 (zero), when the widget has not been rendered on the screen. |