<layout>
Abstract layout base class.
A layout is used to automatically distribute, align, or
otherwise arrange the subviews of the view that contains it (it
arranges the views that are it's siblings). Using a layout
obviates the need to precisely position the views of an
application and allows an application to resize or reconfigure
gracefully according to the constraints of its container.
The layout class is a null layout — it does not arrange
it's siblings. It is the base class that other layouts extend.
simplelayout
is a basic extension of the
layout class. The example below illustrates using a simple
layout to distribute views along the y axis.
Example 8. Using a simple layout to arrange views
<canvas
height
="60
">
<view
bgcolor
="#DDFFFF
">
<text
>Without a layout, it can be difficult
</text
>
<text
x
="2
" y
="5
">to manually position your views
</text
>
</view
>
<view
y
="25
" bgcolor
="#FFDDFF
">
<simplelayout
axis
="y
"/>
<text
>A layout makes
</text
>
<text
>positioning simple and automatic
</text
>
</view
>
</canvas
>
Layouts are so important, there is a shorthand for specifying them
using the ??? attribute
of <view>. The previous example could be more
compactly specified:
Example 9. Using the layout attribute to specify a layout
<canvas
height
="35
">
<view
layout
="class: simplelayout; axis: y
">
<text
>A layout makes
</text
>
<text
>positioning simple and automatic
</text
>
</view
>
</canvas
>
Because <simplelayout> is the default
layout, the above example could also have used just layout="axis:
y"
.
Layouts, like constraints and animators, affect specific
attributes of a view. Views can have more than one layout, as long
as each set of attributes associated with a layout does not
overlap with any of the other sets.
layout.lzx
Attributes inherited from <node>
classroot, cloneManager, data, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, styleclass, subnodes, transition
Methods
-
-
layout.addSubview(sd : lz.view);
Called whenever a new subview is added to the layout. This is called both
in the layout constructor and when a new subview is called after layout
has been created. This is only called if the view's "ignorelayout" option is
not set. Subclasses may override this method to decide whether or
not to add a particular view to the
subviews
array.
-
-
layout.ignore(s : lz.view);
Called when a subview is to be ignored by the layout. By default, most
layouts include all the subviews of a given view.
-
-
Lock the layout from processing updates. This allows the layout to register
for events that it generates itself. Unfortunately, right now all subclass
routines that can generate calls that may result in the layout calling
itself should check the lock before processing. Failure to do so is not
catastrophic, but it will slow down your program.
-
-
layout.releaseLayout(fromdestroy);
|
This method is deprecated |
will be removed from a future release. |
Remove the layout from the view and unregister the delegates that the layout
uses.
-
-
layout.removeSubview(sd : lz.view);
Called when a subview is removed. This is not well tested.
-
-
Reset any held parameters (such as kept sizes that may have changed) and
before updating.
-
-
layout.setLayoutOrder(sub1 : lz.view, sub2 : lz.view);
Reorder the second subview given to this function so that it immediately
follows the first. Doesn't touch the placement of the first subview given
-
-
layout.swapSubviewOrder(sub1 : lz.view, sub2 : lz.view);
Swap the positions of the two subviews within the layout
-
-
layout.unlock(ignore : Any);
Unlock the layout once update is done.
-
-
Update is called whenever the layout needs to be updated.
In the layout
class, update does nothing.
Subclasses of layout override this method to implement their
layout algorithm. For best performance, any update method should
check first to see if the layout is locked
and return
immediately if so. This will avoid redundant updates when a
layout is in transition.
Methods inherited from <node>
animate, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setOption, setSelected, updateData