# Class LayeredLayout

java.lang.Object
com.codename1.ui.layouts.Layout
com.codename1.ui.layouts.LayeredLayout

public class LayeredLayout extends Layout

The `LayeredLayout` places the components in order one on top of the other and sizes them all to the size of the largest component. This is useful when trying to create an overlay on top of an existing component. E.g. an "x" button to allow removing the component as shown here

The code to generate this UI is slightly complex and contains very little relevant pieces. The only truly relevant piece the last line of code:

    Form hi = new Form("Layered Layout");
    int w = Math.min(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight());
    Button settingsLabel = new Button("");
    Style settingsStyle = settingsLabel.getAllStyles();
    settingsStyle.setFgColor(0xff);
    settingsStyle.setBorder(null);
    settingsStyle.setBgColor(0xff00);
    settingsStyle.setBgTransparency(255);
    settingsStyle.setFont(settingsLabel.getUnselectedStyle().getFont().derive(w / 3, Font.STYLE_PLAIN));
    FontImage.setMaterialIcon(settingsLabel, FontImage.MATERIAL_SETTINGS);

    Button close = new Button("");
    close.setUIID("Container");
    close.getAllStyles().setFgColor(0xff0000);
    FontImage.setMaterialIcon(close, FontImage.MATERIAL_CLOSE);
    hi.add(LayeredLayout.encloseIn(settingsLabel,
            FlowLayout.encloseRight(close)));
    ```*

    We are doing three distinct things here:

    .

    -  We are adding a layered layout to the form.

    -  We are creating a layered layout and placing two components within. This
    would be the equivalent of just creating a `LayeredLaout`
    `com.codename1.ui.Container` and invoking `add` twice.
    .*
    -  We use
    https://www.codenameone.com/javadoc/com/codename1/ui/layouts/FlowLayout.html[FlowLayout]
    to position the `X` close button in the right position.

    A common use case for `LayeredLayout` is the iOS carousel effect which
    we can achieve by combing the `LayeredLayout` with
    `com.codename1.ui.Tabs`.

    ```java
    Form hi = new Form("Swipe Tabs", new LayeredLayout());
    Tabs t = new Tabs();
    t.hideTabs();

    Style s = UIManager.getInstance().getComponentStyle("Button");
    FontImage radioEmptyImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, s);
    FontImage radioFullImage = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, s);
    ((DefaultLookAndFeel)UIManager.getInstance().getLookAndFeel()).setRadioButtonImages(radioFullImage, radioEmptyImage, radioFullImage, radioEmptyImage);

    Container container1 = BoxLayout.encloseY(new Label("Swipe the tab to see more"),
            new Label("You can put anything here"));
    t.addTab("Tab1", container1);
    t.addTab("Tab2", new SpanLabel("Some text directly in the tab"));

    RadioButton firstTab = new RadioButton("");
    RadioButton secondTab = new RadioButton("");
    firstTab.setUIID("Container");
    secondTab.setUIID("Container");
    new ButtonGroup(firstTab, secondTab);
    firstTab.setSelected(true);
    Container tabsFlow = FlowLayout.encloseCenter(firstTab, secondTab);

    hi.add(t);
    hi.add(BorderLayout.south(tabsFlow));

    t.addSelectionListener((i1, i2) -> {
        switch(i2) {
            case 0:
                if(!firstTab.isSelected()) {
                    firstTab.setSelected(true);
                }
                break;
            case 1:
                if(!secondTab.isSelected()) {
                    secondTab.setSelected(true);
                }
                break;
         }
    });

Notice that the layered layout sizes all components to the exact same size one on top of the other. It usually requires that we use another container within; in order to position the components correctly.

Forms have a built in layered layout that you can access via `getLayeredPane()`, this allows you to overlay elements on top of the content pane.

The layered pane is used internally by components such as `com.codename1.components.InteractionDialog`, `com.codename1.u./AutoCompleteTextField` etc.

Warning: Placing native widgets within a layered layout is problematic due to the behavior of peer components. Sample of peer components include the `com.codename1.ui.BrowserComponent`, video playback etc.

Insets

This layout optionally supports insets for laying out its children. Use of insets can allow you to achieve precise placement of components while adjusting properly to screen resizing.

Insets may be either fixed or flexible. Fixed insets may be specified in pixels (`#UNIT_PIXELS`), millimetres (`#UNIT_DIPS`), or percentage (`#UNIT_PERCENT`). Insets may also be specified as just "auto" (`#UNIT_AUTO`), in which case it is considered to be flexible (it will adapt to the component size and other insets).

Insets may also be anchored to a "reference component" so that it will always be measured from that reference component.

Insets Example

Adding a button to the top right of the parent:

    `Container cnt = new Container(new LayeredLayout());
    LayeredLayout ll = (LayeredLayout)cnt.getLayout();
    Button btn = new Button("My Button");
    cnt.add(btn);
    ll.setInsets(btn, "0 0 auto auto");
        // NOTE: Insets are expressed in same order as "margin" in CSS.  Clockwise starting on top.`

Changing top inset to 2mm, and right inset to 1mm:

    `ll.setInsets(btn, "2mm 1mm auto auto");`

Using percentage insets:

    `ll.setInsets(btn, "25% 25% auto auto");`

NOTE: When using percent units, the percentage is always in terms of the "reference box" of the component. The "reference box" is the bounding rectangle from which the insets are measured. If none of the insets is anchored to a reference component, then the bounding box will simply be the inner bounds of the parent container (i.e. the bounds of the inside padding in the container.

Using "auto" insets

An "auto" inset is an inset that is flexible. If all 4 insets are set to auto, then the component will tend to the centre of the parent component, and its size will be the component's preferred size (though the size will be bounded by the size of the component's reference box). If one inset is fixed, and the opposite inset is "auto", then the fixed inset and the component's preferred size will dictate the' calculated size of the inset.

Reference Components

Insets may also have reference componnents. E.g. If you want a button to be anchored to the right side of a search field, you could make the button's left inset "reference" the text field. This would be achieved as follows:

    `Container cnt = new Container(new LayeredLayout());
    LayeredLayout ll = (LayeredLayout)cnt.getLayout();
    TextField searchField = new TextField();
    Button btn = new Button("Search");
    cnt.add(searchField).add(btn);
    ll
      .setInsets(searchField, "1mm auto auto auto")
      .setInsets(btn, "0 auto auto 0")
      .setReferenceComponentLeft(btn, searchField, 1f)
      .setReferenceComponentTop(btn, searchField, 0);`

In the above example we set the search field to be anchored to the top of its parent (1mm inset), but for all other insets to be auto. This will result it being centered horizontally in its parent. We then anchor the button to the left and top of the search field so that the top and left insets of button will always be calculated relative to the position of searchField. In particular since the button has top and left insets of 0, the button will always be placed just to the right of the search field, with its top edge aligned with the top edge of search field.

Reference Positions

The second parameter of `setReferenceComponentLeft(btn, searchField, 1f)` is the reference position and it dictates which edge of the reference component (searchField) the inset should be anchored to. A value of 1 indicates that it should anchor to the opposite side of the inset (e.g. in this case it is the "left" inset we are setting, so the 1 value dictates that it is anchored to the "right" side of the text field. A value of 0 indicates that it should anchor to the same side as the inset. This is why we used 0 in the subsequent call to `.setReferenceComponentTop(btn, searchField, 0);`, because we want to anchor the "top" inset of button to the "top" edge of searchField.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `class`
  `LayeredLayout.LayeredLayoutConstraint`
  A class that encapsulates the insets for a component in layered layout.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final byte`
  `UNIT_AUTO`
  Unit used for insets.
  `static final byte`
  `UNIT_BASELINE`
  Unit used for insets.
  `static final byte`
  `UNIT_DIPS`
  Unit used for insets.
  `static final byte`
  `UNIT_PERCENT`
  Unit used for insets.
  `static final byte`
  `UNIT_PIXELS`
  Unit used for insets.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LayeredLayout()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addLayoutComponent(Object value, Component comp, Container c)`
  Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.
  `Object`
  `cloneConstraint(Object constraint)`
  Makes a copy of the given constraint.
  `LayeredLayout.LayeredLayoutConstraint`
  `createConstraint()`
  Creates a new `LayeredLayoutConstraint`
  `LayeredLayout.LayeredLayoutConstraint`
  `createConstraint(String constraint)`
  Creates a default layered layout constraint.
  `static Container`
  `encloseIn(Component... cmps)`
  Shorthand for Container.encloseIn(new LayeredLayout(), cmps);
  `String`
  `getBottomInsetAsString(Component cmp)`
  Gets the bottom inset as a string.
  `protected Component[]`
  `getChildrenInTraversalOrder(Container parent)`
  Gets the children of the parent container in the order that they should be traversed when tabbing through a form.
  `Object`
  `getComponentConstraint(Component comp)`
  Gets the LayeredLayoutConstraint associated with the given component.
  `LayeredLayout.LayeredLayoutConstraint.Inset`
  `getInset(Component cmp, int side)`
  Gets an `Inset` associated with the provided component
  `String`
  `getInsetsAsString(Component cmp, boolean withLabels)`
  Returns the insets for the given component as a string.
  `LayeredLayout.LayeredLayoutConstraint`
  `getLayeredLayoutConstraint(Component cmp)`
  Wraps `#getComponentConstraint(com.codename1.ui.Component)` and casts it directly to `LayeredLayoutConstraint`.
  `String`
  `getLeftInsetAsString(Component cmp)`
  Gets the left inset as a string.
  `LayeredLayout.LayeredLayoutConstraint`
  `getOrCreateConstraint(Component cmp)`
  If the given component already has a LayeredLayoutConstraint, then this will return it.
  `float`
  `getPercentInsetAnchorHorizontal(Component cmp)`
  See `LayeredLayoutConstraint#getPercentInsetAnchorHorizontal()`
  `float`
  `getPercentInsetAnchorVertical(Component cmp)`
  See `LayeredLayoutConstraint#getPercentInsetAnchorVertical()`
  `float`
  `getPreferredHeightMM()`
  The preferred height in MM of this layout which serves as a sort of minimum height even when the components in the layout don't demand space.
  `Dimension`
  `getPreferredSize(Container parent)`
  Returns the container preferred size
  `float`
  `getPreferredWidthMM()`
  The preferred width (in MM) of this layout which serves as a sort of minimum width even when the components in the layout don't demand space.
  `String`
  `getRightInsetAsString(Component cmp)`
  Gets the right inset as a string.
  `String`
  `getTopInsetAsString(Component cmp)`
  Gets the top inset as a string.
  `boolean`
  `isOverlapSupported()`
  This method returns true if the Layout allows Components to Overlap.
  `void`
  `layoutContainer(Container parent)`
  Layout the given parent container children
  `boolean`
  `obscuresPotential(Container parent)`
  Some layout managers can obscure their child components in some cases this returns true if the basic underpinnings are in place for that.
  `boolean`
  `overridesTabIndices(Container parent)`
  If a layout specifies a different traversal order of its components than the component index, then it should override this method to return true, and it should also override `#getChildrenInTraversalOrder(com.codename1.ui.Container)` to set the tab indices of a container's children.
  `LayeredLayout`
  `setInsetBottom(Component cmp, String inset)`
  Sets the top inset for this component to the prescribed value.
  `LayeredLayout`
  `setInsetLeft(Component cmp, String inset)`
  Sets the left inset for this component to the prescribed value.
  `LayeredLayout`
  `setInsetRight(Component cmp, String inset)`
  Sets the right inset for this component to the prescribed value.
  `LayeredLayout`
  `setInsets(Component cmp, String insets)`
  Sets the insets for the component cmp to the values specified in insets.
  `LayeredLayout`
  `setInsetTop(Component cmp, String inset)`
  Sets the top inset for this component to the prescribed value.
  `LayeredLayout`
  `setPercentInsetAnchorHorizontal(Component cmp, float anchor)`
  See `LayeredLayoutConstraint#setPercentInsetAnchorHorizontal(float)`
  `LayeredLayout`
  `setPercentInsetAnchorVertical(Component cmp, float anchor)`
  See `LayeredLayoutConstraint#setPercentInsetAnchorVertical(float)`
  `void`
  `setPreferredHeightMM(float mm)`
  Sets the preferred height of this layout in MM.
  `void`
  `setPreferredSizeMM(float width, float height)`
  Sets the preferred size of this layout in MM.
  `void`
  `setPreferredWidthMM(float mm)`
  Sets the preferred width of this layout in MM.
  `LayeredLayout`
  `setReferenceComponentBottom(Component cmp, Component referenceComponent)`
  Sets the reference component for the bottom inset of the given component.
  `LayeredLayout`
  `setReferenceComponentBottom(Component cmp, Component referenceComponent, float position)`
  Sets the reference component for the bottom inset of the given component.
  `LayeredLayout`
  `setReferenceComponentLeft(Component cmp, Component referenceComponent)`
  Sets the reference component for the left inset of the given component.
  `LayeredLayout`
  `setReferenceComponentLeft(Component cmp, Component referenceComponent, float position)`
  Sets the reference component for the left inset of the given component.
  `LayeredLayout`
  `setReferenceComponentRight(Component cmp, Component referenceComponent)`
  Sets the reference component for the right inset of the given component.
  `LayeredLayout`
  `setReferenceComponentRight(Component cmp, Component referenceComponent, float position)`
  Sets the reference component for the right inset of the given component.
  `LayeredLayout`
  `setReferenceComponents(Component cmp, Component... referenceComponents)`
  Sets the reference components for the insets of cmp.
  `LayeredLayout`
  `setReferenceComponents(Component cmp, String refs)`
  Sets the reference components for this component as a string of 1 to 4 component indices separated by spaces.
  `LayeredLayout`
  `setReferenceComponentTop(Component cmp, Component referenceComponent)`
  Sets the reference component for the top inset of the given component.
  `LayeredLayout`
  `setReferenceComponentTop(Component cmp, Component referenceComponent, float position)`
  Sets the reference component for the top inset of the given component.
  `LayeredLayout`
  `setReferencePositionBottom(Component cmp, float position)`
  Sets the bottom inset reference position.
  `LayeredLayout`
  `setReferencePositionLeft(Component cmp, float position)`
  Sets the left inset reference position.
  `LayeredLayout`
  `setReferencePositionRight(Component cmp, float position)`
  Sets the right inset reference position.
  `LayeredLayout`
  `setReferencePositions(Component cmp, float... referencePositions)`
  Sets the reference positions for reference components.
  `LayeredLayout`
  `setReferencePositions(Component cmp, String positions)`
  Sets the reference positions for reference components.
  `LayeredLayout`
  `setReferencePositionTop(Component cmp, float position)`
  Sets the top inset reference position.
  `String`
  `toString()`
  Returns a string representation of the object.

  ### Methods inherited from class Layout

  `equals, hashCode, isConstraintTracking, removeLayoutComponent, updateTabIndices`

  ### Methods inherited from class Object

  `clone, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### UNIT_DIPS

    public static final byte UNIT_DIPS

    Unit used for insets. Millimetres.

    ###### See also

    - Inset#unit(byte)

    - Inset#changeUnits(byte)

    See Also:
      - Constant Field Values

  - ### UNIT_PIXELS

    public static final byte UNIT_PIXELS

    Unit used for insets. Pixels.

    ###### See also

    - Inset#unit(byte)

    - Inset#changeUnits(byte)

    See Also:
      - Constant Field Values

  - ### UNIT_PERCENT

    public static final byte UNIT_PERCENT

    Unit used for insets. Percent.

    ###### See also

    - Inset#unit(byte)

    - Inset#changeUnits(byte)

    See Also:
      - Constant Field Values

  - ### UNIT_AUTO

    public static final byte UNIT_AUTO

    Unit used for insets. Auto. Auto unit type for an inset indicates the the inset will be automatically determined at layout time.

    ###### See also

    - Inset#unit(byte)

    - Inset#changeUnits(byte)

    See Also:
      - Constant Field Values

  - ### UNIT_BASELINE

    public static final byte UNIT_BASELINE
    Unit used for insets. Baseline. Baseline unit type for an inset indicates the inset will be aligned with the baseline of the reference component. This only makes sense for the top inset. The height will automatically become the preferred height and the bottom inset will become "auto" if the top inset uses the baseline unit.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### LayeredLayout

    public LayeredLayout()

- ## Method Details

  - ### encloseIn

    public static Container encloseIn(Component... cmps)

    Shorthand for Container.encloseIn(new LayeredLayout(), cmps);

    ###### Parameters

    - `cmps`: the components to add to a new layered layout container

    ###### Returns

    a newly created layered layout

  - ### setPreferredSizeMM

    public void setPreferredSizeMM(float width, float height)

    Sets the preferred size of this layout in MM. This serves as a minimum size that will be returned by calcPreferredSize().

    ###### Parameters

    - `width`: The preferred width in MM.

    - `height`: The preferred height in MM.

  - ### getPreferredHeightMM

    public float getPreferredHeightMM()

    The preferred height in MM of this layout which serves as a sort of minimum height even when the components in the layout don't demand space.

    The actual preferred height will be the max of this value and the calculated preferred height based on the container's children.

  - ### setPreferredHeightMM

    public void setPreferredHeightMM(float mm)

    Sets the preferred height of this layout in MM.

    ###### Parameters

    - `mm`

  - ### getPreferredWidthMM

    public float getPreferredWidthMM()

    The preferred width (in MM) of this layout which serves as a sort of minimum width even when the components in the layout don't demand space.

    The actual preferred width will be the max of this value and the calculated preferred width based on the container's children.

  - ### setPreferredWidthMM

    public void setPreferredWidthMM(float mm)

    Sets the preferred width of this layout in MM.

    ###### Parameters

    - `mm`

  - ### addLayoutComponent

    public void addLayoutComponent(Object value, Component comp, Container c)
    Description copied from class: `Layout`

    Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.

    ###### Parameters

    - `value`: optional meta data information, like alignment orientation

    - `comp`: the added component to the layout

    - `c`: the parent container

    Overrides:
      `addLayoutComponent` in class `Layout`

  - ### getLayeredLayoutConstraint

    public LayeredLayout.LayeredLayoutConstraint getLayeredLayoutConstraint(Component cmp)

    Wraps `#getComponentConstraint(com.codename1.ui.Component)` and casts it directly to `LayeredLayoutConstraint`.

    ###### Parameters

    - `cmp`: The component whose constraint we want to retrieve.

    ###### Returns

    The layered layout constraint for this component.

  - ### cloneConstraint

    public Object cloneConstraint(Object constraint)

    Makes a copy of the given constraint.

    ###### Parameters

    - `constraint`: The constraint to copy.

    ###### Returns

    The copied constraint.

    Overrides:
      `cloneConstraint` in class `Layout`

  - ### getComponentConstraint

    public Object getComponentConstraint(Component comp)

    Gets the LayeredLayoutConstraint associated with the given component.

    May return null if there is no constraint.

    ###### Parameters

    - `comp`
    Overrides:
      `getComponentConstraint` in class `Layout`

  - ### createConstraint

    public LayeredLayout.LayeredLayoutConstraint createConstraint(String constraint)

    Creates a default layered layout constraint. Default constraint has zero insets on all four sides.

    ###### Parameters

    - `constraint`

  - ### getOrCreateConstraint

    public LayeredLayout.LayeredLayoutConstraint getOrCreateConstraint(Component cmp)

    If the given component already has a LayeredLayoutConstraint, then this will return it. Otherwise it will create a constraint, install it in cmp and return the constraint for inspection or manipulation.

    ###### Parameters

    - `cmp`: The component whose constraint we wish to retrieve.

    ###### Returns

    The constraint for a given component.

  - ### getInset

    public LayeredLayout.LayeredLayoutConstraint.Inset getInset(Component cmp, int side)

    Gets an `Inset` associated with the provided component

    ###### Parameters

    - `cmp`: The component whose inset we wish to retrieve.

    - `side`: @param side The side of the inset. One of `Component#TOP`, `Component#LEFT`, `Component#BOTTOM` or `Component#RIGHT`.

    ###### Returns

    The `Inset` for the given side of the component.

  - ### getInsetsAsString

    public String getInsetsAsString(Component cmp, boolean withLabels)

    Returns the insets for the given component as a string. This can return the insets in one of two formats depending on the value of the withLabels parameter.

    ###### Parameters

    - `cmp`: The component whose insets we wish to retrieve.

    - `withLabels`: @param withLabels If false, then this returns a string of the format `"top right bottom left"` e.g `"2mm 2mm 2mm 2mm"`. If true, then it will be formatted like CSS properties: `"top:2mm; right:2mm; bottom:2mm; left:2mm"`.

    ###### Returns

    Returns:

      The insets associated with cmp as a string. Each inset will include the unit. E.g.:

      - 2mm = 2 millimetres/dips
      - 2px = 2 pixels
      - 25% = 25%
      - auto = Flexible inset

  - ### getTopInsetAsString

    public String getTopInsetAsString(Component cmp)

    Gets the top inset as a string. Return value will include the unit, so the following are possible values:

    - 2mm = 2 millimetres

    - 2px = 2 pixels

    - 25% = 25%

    - auto = Flexible Inset

    ###### Parameters

    - `cmp`: The component whose inset we wish to retrieve.

    ###### Returns

    The inset formatted as a string with the unit abbreviation ("mm", "px", or "%") suffixed.

  - ### getBottomInsetAsString

    public String getBottomInsetAsString(Component cmp)

    Gets the bottom inset as a string. Return value will include the unit, so the following are possible values:

    - 2mm = 2 millimetres

    - 2px = 2 pixels

    - 25% = 25%

    - auto = Flexible Inset

    ###### Parameters

    - `cmp`: The component whose inset we wish to retrieve.

    ###### Returns

    The inset formatted as a string with the unit abbreviation ("mm", "px", or "%") suffixed.

  - ### getLeftInsetAsString

    public String getLeftInsetAsString(Component cmp)

    Gets the left inset as a string. Return value will include the unit, so the following are possible values:

    - 2mm = 2 millimetres

    - 2px = 2 pixels

    - 25% = 25%

    - auto = Flexible Inset

    ###### Parameters

    - `cmp`: The component whose inset we wish to retrieve.

    ###### Returns

    The inset formatted as a string with the unit abbreviation ("mm", "px", or "%") suffixed.

  - ### getRightInsetAsString

    public String getRightInsetAsString(Component cmp)

    Gets the right inset as a string. Return value will include the unit, so the following are possible values:

    - 2mm = 2 millimetres

    - 2px = 2 pixels

    - 25% = 25%

    - auto = Flexible Inset

    ###### Parameters

    - `cmp`: The component whose inset we wish to retrieve.

    ###### Returns

    The inset formatted as a string with the unit abbreviation ("mm", "px", or "%") suffixed.

  - ### setInsets

    public LayeredLayout setInsets(Component cmp, String insets)

    Sets the insets for the component cmp to the values specified in insets.

    ###### Parameters

    - `cmp`: The component whose insets we wish to set.

    - `insets`: @param insets The insets expressed as a string. See `LayeredLayoutConstraint#setInsets(java.lang.String)` for details on the format of this parameter.

    ###### Returns

    Self for chaining.

    ###### See also

    See Also:
      - For details on the insets parameter format.

  - ### setInsetTop

    public LayeredLayout setInsetTop(Component cmp, String inset)

    Sets the top inset for this component to the prescribed value.

    ###### Parameters

    - `cmp`: The component whose inset we wish to set.

    - `inset`: @param inset The inset value, including unit. Units are Percent (%), Millimetres (mm), Pixels (px), and "auto". E.g. the following insets values would all be acceptable:

    - `"2mm"` = 2 millimetres

    - `"2px"` = 2 pixels

    - `"25%"` = 25 percent.

    - `"auto"` = Flexible inset

    ###### Returns

    Self for chaining.

  - ### setInsetBottom

    public LayeredLayout setInsetBottom(Component cmp, String inset)

    Sets the top inset for this component to the prescribed value.

    ###### Parameters

    - `cmp`: The component whose inset we wish to set.

    - `inset`: @param inset The inset value, including unit. Units are Percent (%), Millimetres (mm), Pixels (px), and "auto". E.g. the following insets values would all be acceptable:

    - `"2mm"` = 2 millimetres

    - `"2px"` = 2 pixels

    - `"25%"` = 25 percent.

    - `"auto"` = Flexible inset

    ###### Returns

    Self for chaining.

  - ### setInsetLeft

    public LayeredLayout setInsetLeft(Component cmp, String inset)

    Sets the left inset for this component to the prescribed value.

    ###### Parameters

    - `cmp`: The component whose inset we wish to set.

    - `inset`: @param inset The inset value, including unit. Units are Percent (%), Millimetres (mm), Pixels (px), and "auto". E.g. the following insets values would all be acceptable:

    - `"2mm"` = 2 millimetres

    - `"2px"` = 2 pixels

    - `"25%"` = 25 percent.

    - `"auto"` = Flexible inset

    ###### Returns

    Self for chaining.

  - ### setInsetRight

    public LayeredLayout setInsetRight(Component cmp, String inset)

    Sets the right inset for this component to the prescribed value.

    ###### Parameters

    - `cmp`: The component whose inset we wish to set.

    - `inset`: @param inset The inset value, including unit. Units are Percent (%), Millimetres (mm), Pixels (px), and "auto". E.g. the following insets values would all be acceptable:

    - `"2mm"` = 2 millimetres

    - `"2px"` = 2 pixels

    - `"25%"` = 25 percent.

    - `"auto"` = Flexible inset

    ###### Returns

    Self for chaining.

  - ### setReferenceComponents

    public LayeredLayout setReferenceComponents(Component cmp, Component... referenceComponents)

    Sets the reference components for the insets of cmp. See `LayeredLayoutConstraint#setReferenceComponents(com.codename1.ui.Component...)` for a full description of the parameters.

    ###### Parameters

    - `cmp`: The component whose reference components we wish to check.

    - `referenceComponents`: @param referenceComponents The reference components. This var arg may contain 1 to 4 values. See `LayeredLayoutConstraint#setReferenceComponents(com.codename1.ui.Component...)` for a full description.

    ###### Returns

    Self for chaining.

  - ### setReferenceComponents

    public LayeredLayout setReferenceComponents(Component cmp, String refs)

    Sets the reference components for this component as a string of 1 to 4 component indices separated by spaces. An index of -1 indicates no reference for the corresponding inset. See `java.lang.String)` for a description of the refs parameter.

    ###### Parameters

    - `cmp`: The component whose references we're setting.

    - `refs`: Reference components as a string of component indices in the parent.

    ###### Returns

    Self for chaining.

  - ### setReferenceComponentTop

    public LayeredLayout setReferenceComponentTop(Component cmp, Component referenceComponent)

    Sets the reference component for the top inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to anchor the inset to.

    ###### Returns

    Self for chaining.

  - ### setReferenceComponentBottom

    public LayeredLayout setReferenceComponentBottom(Component cmp, Component referenceComponent)

    Sets the reference component for the bottom inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to anchor the inset to.

    ###### Returns

    Self for chaining.

  - ### setReferenceComponentLeft

    public LayeredLayout setReferenceComponentLeft(Component cmp, Component referenceComponent)

    Sets the reference component for the left inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to anchor the inset to.

    ###### Returns

    Self for chaining.

  - ### setReferenceComponentRight

    public LayeredLayout setReferenceComponentRight(Component cmp, Component referenceComponent)

    Sets the reference component for the right inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to anchor the inset to.

    ###### Returns

    Self for chaining.

  - ### setReferencePositions

    public LayeredLayout setReferencePositions(Component cmp, float... referencePositions)

    Sets the reference positions for reference components. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a description of the parameters.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referencePositions`: @param referencePositions The reference positions for the reference components. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of this parameter.

    ###### Returns

    Self for chaining.

  - ### setReferencePositions

    public LayeredLayout setReferencePositions(Component cmp, String positions)

    Sets the reference positions for reference components. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a description of the parameters.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `positions`: @param positions The reference positions for the reference components. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of this parameter.

    ###### Returns

    Self for chaining.

  - ### setReferencePositionTop

    public LayeredLayout setReferencePositionTop(Component cmp, float position)

    Sets the top inset reference position. Only applicable if the top inset has a reference component specified.

    ###### Parameters

    - `cmp`: The component whose insets were are manipulating.

    - `position`: @param position The position. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of the possible values here.

  - ### setReferenceComponentTop

    public LayeredLayout setReferenceComponentTop(Component cmp, Component referenceComponent, float position)

    Sets the reference component for the top inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to which the inset should be anchored.

    - `position`: @param position The position of the reference anchor. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of reference positions.

  - ### setReferencePositionBottom

    public LayeredLayout setReferencePositionBottom(Component cmp, float position)

    Sets the bottom inset reference position. Only applicable if the top inset has a reference component specified.

    ###### Parameters

    - `cmp`: The component whose insets were are manipulating.

    - `position`: @param position The position. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of the possible values here.

  - ### setReferenceComponentBottom

    public LayeredLayout setReferenceComponentBottom(Component cmp, Component referenceComponent, float position)

    Sets the reference component for the bottom inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to which the inset should be anchored.

    - `position`: @param position The position of the reference anchor. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of reference positions.

  - ### setReferencePositionLeft

    public LayeredLayout setReferencePositionLeft(Component cmp, float position)

    Sets the left inset reference position. Only applicable if the top inset has a reference component specified.

    ###### Parameters

    - `cmp`: The component whose insets were are manipulating.

    - `position`: @param position The position. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of the possible values here.

  - ### setReferenceComponentLeft

    public LayeredLayout setReferenceComponentLeft(Component cmp, Component referenceComponent, float position)

    Sets the reference component for the left inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to which the inset should be anchored.

    - `position`: @param position The position of the reference anchor. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of reference positions.

  - ### setReferencePositionRight

    public LayeredLayout setReferencePositionRight(Component cmp, float position)

    Sets the right inset reference position. Only applicable if the top inset has a reference component specified.

    ###### Parameters

    - `cmp`: The component whose insets were are manipulating.

    - `position`: @param position The position. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of the possible values here.

  - ### setReferenceComponentRight

    public LayeredLayout setReferenceComponentRight(Component cmp, Component referenceComponent, float position)

    Sets the reference component for the right inset of the given component.

    ###### Parameters

    - `cmp`: The component whose insets we are manipulating.

    - `referenceComponent`: The component to which the inset should be anchored.

    - `position`: @param position The position of the reference anchor. See `LayeredLayoutConstraint#setReferencePositions(float...)` for a full description of reference positions.

  - ### setPercentInsetAnchorHorizontal

    public LayeredLayout setPercentInsetAnchorHorizontal(Component cmp, float anchor)

    See `LayeredLayoutConstraint#setPercentInsetAnchorHorizontal(float)`

    ###### Parameters

    - `cmp`

    - `anchor`

    ###### Returns

    Self for chaining

  - ### setPercentInsetAnchorVertical

    public LayeredLayout setPercentInsetAnchorVertical(Component cmp, float anchor)

    See `LayeredLayoutConstraint#setPercentInsetAnchorVertical(float)`

    ###### Parameters

    - `cmp`

    - `anchor`

    ###### Returns

    Self for chaining

  - ### getPercentInsetAnchorHorizontal

    public float getPercentInsetAnchorHorizontal(Component cmp)

    See `LayeredLayoutConstraint#getPercentInsetAnchorHorizontal()`

    ###### Parameters

    - `cmp`

  - ### getPercentInsetAnchorVertical

    public float getPercentInsetAnchorVertical(Component cmp)

    See `LayeredLayoutConstraint#getPercentInsetAnchorVertical()`

    ###### Parameters

    - `cmp`

  - ### layoutContainer

    public void layoutContainer(Container parent)

    Layout the given parent container children

    ###### Parameters

    - `parent`: the given parent container
    Specified by:
      `layoutContainer` in class `Layout`

  - ### getPreferredSize

    public Dimension getPreferredSize(Container parent)

    Returns the container preferred size

    ###### Parameters

    - `parent`: the parent container

    ###### Returns

    the container preferred size

    Specified by:
      `getPreferredSize` in class `Layout`

  - ### toString

    public String toString()
    Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
    Overrides:
      `toString` in class `Object`

  - ### isOverlapSupported

    public boolean isOverlapSupported()

    This method returns true if the Layout allows Components to Overlap.

    ###### Returns

    true if Components may intersect in this layout

    Overrides:
      `isOverlapSupported` in class `Layout`

  - ### obscuresPotential

    public boolean obscuresPotential(Container parent)

    Some layout managers can obscure their child components in some cases this returns true if the basic underpinnings are in place for that. This method doesn't take padding/margin etc. into account since that is checked by the caller

    ###### Parameters

    - `parent`: parent container

    ###### Returns

    true if there is a chance that this layout manager can fully obscure the background, when in doubt return false...

    Overrides:
      `obscuresPotential` in class `Layout`

  - ### createConstraint

    public LayeredLayout.LayeredLayoutConstraint createConstraint()
    Creates a new `LayeredLayoutConstraint`

  - ### overridesTabIndices

    public boolean overridesTabIndices(Container parent)
    Description copied from class: `Layout`

    If a layout specifies a different traversal order of its components than the component index, then it should override this method to return true, and it should also override `#getChildrenInTraversalOrder(com.codename1.ui.Container)` to set the tab indices of a container's children.

    ###### Parameters

    - `parent`: The parent component.

    ###### Returns

    True if this layout overrides tab traversal order.

    Overrides:
      `overridesTabIndices` in class `Layout`

  - ### getChildrenInTraversalOrder

    protected Component[] getChildrenInTraversalOrder(Container parent)
    Description copied from class: `Layout`

    Gets the children of the parent container in the order that they should be traversed when tabbing through a form.

    This should only be overridden if the Layout defines a different traversal order than the standard index order.

    Layouts that implement this method, should override the `#overridesTabIndices(com.codename1.ui.Container)` method to return true.

    ###### Parameters

    - `parent`

    ###### Returns

    Array of Components in the order

    Overrides:
      `getChildrenInTraversalOrder` in class `Layout`