Advanced Topics


View.isViewGroup indicates whether the given view is a view group. A view group can contains other views (called child views). If false, an exception is thrown when View.addChild() is called.


When View.addChild() is called, View will invoke View.addChildNode_() at the end to add the DOM element of the child view into the DOM tree.

By default, the child element will be added right under node. In other words, it assumes the view has only one layer of DOM elements. If you'd like to put the child elements in a particular location, you have to override this method.

For example, assume the child element to put the child elements is identified as cnt, then you can do as follows

void addChildNode_(View child, View beforeChild) {
  if (beforeChild !== null)
    super.addChildNode_(child, beforeChild);

View.mount_() and View.unmount_()

When a hierarchy of views are added to the browser (i.e., View.addToDocument() is called), View.mount_() will be called for every view in the hierarchy.

Similarly, View.unmount_() will be called if it is detached (i.e., View.remove()).

For example, if you want Layout Manager to defer until a particular image is loaded, you can do as follows.

void mount_() {
  super.mount_(); //call back super first

LayoutManager.waitImageLoaded() is a utility to have the layout manager wait for particular image to load before handling the layout of views.