This layout places views on top of each other. As with SimpleLayout, you specify the axis attribute. The value attribute specifies the number of pixels the axis is shifted from. Any view managed by ConstantLayout may have its xoffset and yoffset attributes assigned a value. The xoffset attribute shifts the view to the right or to the left. The yoffset attribute causes the view to be shifted vertically.
Table 4.7 shows the attributes defined in the ConstantLayout 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.10 shows how to use ConstantLayout.
<canvas height="80"> <constantlayout 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> |
To compile this code, invoke the following URL:
http://localhost:8080/lps-4.0.x/app04/constantLayoutTest1.lzx
Upon successful compilation, you will see something similar to Figure 4.10 in your browser.