**Design Doc of RelativeLayout** *Last updated: April 3rd 2018* Overview ======== RelativeLayout supports dragging, resizing, and constraint creation in Layout Editor. Resizing ======== RelativeLayout offers `RelativeResizeTarget` to support resizing function. Resizing doesn't create or remove any constraint. Instead of that, it updates the margin value(s). Constraint Creation =================== RelativeLayout offers `RelativeAnchorTarget` to support constraint creation. Dragging from one anchor to another anchor create a constraint. Only legal anchor should be display while dragging the anchor. It is possible to drag the anchor to the parent to create the Constraint to the parent as well. Dragging ======== RelativeLayout offers `RelativeDragHandler` and `RelativeDragTarget` to support dragging behaviours. `RelativeDragHandler` is used when dragging component from Palette or ComponentTree and `RelativeDragTarget` is used to support dragging component inside the RelativeLayout. Dragging Component from Palette ------------------------------- When dragging from Palette, the dragged component is added to RelativeLayout.
Constraint will be automatically added to keep the component at the position where it was dropped. Dragging Component inside RelativeLayout ---------------------------------------- Before AS 3.1, dragging component used to change the constraints. But it is because we didn't provide other way to create the constraint. Since RelativeLayout now offers the anchor to create the constraint, dragging inside RelativeLayout doesn't add or remove any constraint anymore.
If it already has constraint in the given direction, the corresponding margin is updated. Otherwise it creates the constraint related to RelativeLayout itself.