Simplelayout

出自OpenFace

跳转到: 导航, 搜索

目录

<simplelayout>

A quick layout for arranging siblings vertically or horizontally. JavaScript: simplelayout


Extends Layout simplelayout extends LzLayout, and therefore it is responsible for arranging all of the subviews for the view that it is attached to. The attributes of a view that simplelayout effects are the x and y values. simplelayout places the first subview at (0, 0) and then places each subsequent subview based on the width (or height) of the previous subview, depending on which axis was specified.

The following example illustrates the use of simplelayout.


<canvas height="60">
 <view >
   <simplelayout axis="x" spacing="10"/>
   <view bgcolor="blue" height="30" width="50"/>
   <view bgcolor="blue" height="30" width="50"/>
   <view bgcolor="blue" height="30" width="50"/>
 </view>
</canvas>


More than one layout can be applied to a view as long as the attributes are controlled by only one layout. This next example demonstrates this feature.


<canvas height="120">
 <view >
   <view bgcolor="blue" height="30" width="50"/>
   <view bgcolor="blue" height="30" width="50"/>
   <view bgcolor="blue" height="30" width="50"/>
   <simplelayout axis="x" spacing="0"/>
   <simplelayout axis="y" spacing="0"/>
 </view >
</canvas>


Finally, like all layouts, when an attribute of a subview changes its value and that new value effects the overall layout, then the layout object will update automatically.


Attributes

Name    Usage     Type(Tag)    Type(JS)    Default    Category

axis    Tag & JS    string     String      y       setter

     The axis in which this layout operates. One of 'x' or 'y'.



inset   Tag & JS    expression    any       0        setter

     A pixel amount to inset the first view controlled by the layout



spacing  Tag & JS   expression    any        0        setter

     A pixel amount to use between each view in the layout



Attributes inherited from LzNode

id, name, parent, subnodes


Methods

update()

simplelayout.update() This method is usually called automatically when any of the views controlled by the layout change their size in the layout axis, or their visibility. However it can be called directly to force the layout to update


Methods inherited from LzNode

getAttribute, setAttribute,applyConstraint


Events

Events inherited from LzNode

ondata, oninit