ConstantBoundsLayout is similar to ConstantLayout, but it ignores the xoffset attribute value of any view if the layout’s axis attribute is assigned “x” and ignores the yoffset attribute value of any view if the value of the layout’s axis attribute is “y”.
Table 4.8 shows the attributes defined in the ConstantBoundsLayout class.
Name | Usage | Type | Default | Accessibility |
---|---|---|---|---|
axis | Tag and JS | string | y | read-write |
Description. The axis to lay out components along. The value for this attribute is either “x” or “y”. | ||||
value | Tag and JS | string | read-write | |
Description. The number of pixels the axis is shifted from. |
For example, the code in Listing 4.11 shows how to use ConstantBoundsLayout.
<canvas height="80"> <include href="utils/layouts/constantboundslayout.lzx"/> <constantboundslayout axis="x" value="10"/> <view width="80" height="80" bgcolor="silver" xoffset="-5"/> <view width="60" height="60" bgcolor="gray"/> <view width="40" height="40" bgcolor="black"/> </canvas> |
Note that you need to include the constantboundslayout.lzx file in the utils/layouts directory to use ConstantBoundsLayout.
To compile the code, use this URL:
http://localhost:8080/lps-4.0.x/app04/constantBoundsLayoutTest1.lzx
Figure 4.11 shows the generated output.