Package icyllis.modernui.widget

# Class RelativeLayout.LayoutParams

java.lang.Object
icyllis.modernui.view.ViewGroup.LayoutParams
icyllis.modernui.view.ViewGroup.MarginLayoutParams
icyllis.modernui.widget.RelativeLayout.LayoutParams

Enclosing class:
  `RelativeLayout`

public static class RelativeLayout.LayoutParams extends ViewGroup.MarginLayoutParams
Specifies how a view is positioned within a `RelativeLayout`. The relative layout containing the view uses the value of these layout parameters to determine where to position the view on the screen. If the view is not contained within a relative layout, these attributes are ignored.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `boolean`
  `alignWithParent`
  When true, uses the parent as the anchor if the anchor doesn't exist or if the anchor's visibility is GONE.

  ### Fields inherited from class icyllis.modernui.view.ViewGroup.MarginLayoutParams

  `bottomMargin, DEFAULT_MARGIN_RELATIVE, leftMargin, rightMargin, topMargin`

  ### Fields inherited from class icyllis.modernui.view.ViewGroup.LayoutParams

  `height, MATCH_PARENT, width, WRAP_CONTENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LayoutParams(int width, int height)`
  `LayoutParams(ViewGroup.LayoutParams source)`
  `LayoutParams(ViewGroup.MarginLayoutParams source)`
  `LayoutParams(RelativeLayout.LayoutParams source)`
  Copy constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addRule(int verb)`
  Adds a layout rule to be interpreted by the RelativeLayout.
  `void`
  `addRule(int verb, int subject)`
  Adds a layout rule to be interpreted by the RelativeLayout.
  `int`
  `getRule(int verb)`
  Returns the layout rule associated with a specific verb.
  `int[]`
  `getRules()`
  Retrieves a complete list of all supported rules, where the index is the rule verb, and the element value is the value specified, or "false" if it was never set.
  `int[]`
  `getRules(int layoutDirection)`
  Retrieves a complete list of all supported rules, where the index is the rule verb, and the element value is the value specified, or "false" if it was never set.
  `void`
  `removeRule(int verb)`
  Removes a layout rule to be interpreted by the RelativeLayout.
  `void`
  `resolveLayoutDirection(int layoutDirection)`
  This will be called by `View.requestLayout()` to resolve layout parameters that are relative to the layout direction.

  ### Methods inherited from class icyllis.modernui.view.ViewGroup.MarginLayoutParams

  `copyMarginsFrom, getLayoutDirection, getMarginEnd, getMarginStart, isLayoutRtl, isMarginRelative, onDebugDraw, setLayoutDirection, setMarginEnd, setMargins, setMarginsRelative, setMarginStart`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### alignWithParent

    public boolean alignWithParent
    When true, uses the parent as the anchor if the anchor doesn't exist or if the anchor's visibility is GONE.

- ## Constructor Details

  - ### LayoutParams

    public LayoutParams(int width, int height)

  - ### LayoutParams

    public LayoutParams(@Nonnull ViewGroup.LayoutParams source)

  - ### LayoutParams

    public LayoutParams(@Nonnull ViewGroup.MarginLayoutParams source)

  - ### LayoutParams

    public LayoutParams(@Nonnull RelativeLayout.LayoutParams source)
    Copy constructor. Clones the width, height, margin values, gravity and rules of the source.
    Parameters:
      `source` - the layout params to copy from.

- ## Method Details

  - ### addRule

    public void addRule(int verb)
    Adds a layout rule to be interpreted by the RelativeLayout.

    This method should only be used for verbs that don't refer to a sibling (ex. `RelativeLayout.ALIGN_RIGHT`) or take a boolean value (`RelativeLayout.TRUE` for true or 0 for false). To specify a verb that takes a subject, use `addRule(int, int)`.

    If the rule is relative to the layout direction (ex. `RelativeLayout.ALIGN_PARENT_START`), then the layout direction must be resolved using `resolveLayoutDirection(int)` before calling `getRule(int)` an absolute rule (ex. `RelativeLayout.ALIGN_PARENT_LEFT`.

    Parameters:
      `verb` - a layout verb, such as `RelativeLayout.ALIGN_PARENT_LEFT`
    See Also:
      - `addRule(int, int)`
      - `removeRule(int)`
      - `getRule(int)`

  - ### addRule

    public void addRule(int verb, int subject)
    Adds a layout rule to be interpreted by the RelativeLayout.

    Use this for verbs that refer to a sibling (ex. `RelativeLayout.ALIGN_RIGHT`) or take a boolean value (ex. `RelativeLayout.CENTER_IN_PARENT`).

    If the rule is relative to the layout direction (ex. `RelativeLayout.START_OF`), then the layout direction must be resolved using `resolveLayoutDirection(int)` before calling `getRule(int)` with an absolute rule (ex. `RelativeLayout.LEFT_OF`.

    Parameters:
      `verb` - a layout verb, such as `RelativeLayout.ALIGN_RIGHT`
      `subject` - the ID of another view to use as an anchor, or a boolean value (represented as `RelativeLayout.TRUE` for true or 0 for false)
    See Also:
      - `addRule(int)`
      - `removeRule(int)`
      - `getRule(int)`

  - ### removeRule

    public void removeRule(int verb)
    Removes a layout rule to be interpreted by the RelativeLayout.

    If the rule is relative to the layout direction (ex. `RelativeLayout.START_OF`, `RelativeLayout.ALIGN_PARENT_START`, etc.) then the layout direction must be resolved using `resolveLayoutDirection(int)` before before calling `getRule(int)` with an absolute rule (ex. `RelativeLayout.LEFT_OF`.

    Parameters:
      `verb` - One of the verbs defined by `RelativeLayout`, such as ALIGN_WITH_PARENT_LEFT.
    See Also:
      - `addRule(int)`
      - `addRule(int, int)`
      - `getRule(int)`

  - ### getRule

    public int getRule(int verb)
    Returns the layout rule associated with a specific verb.
    Parameters:
      `verb` - one of the verbs defined by `RelativeLayout`, such as ALIGN_WITH_PARENT_LEFT
    Returns:
      the id of another view to use as an anchor, a boolean value (represented as `RelativeLayout.TRUE` for true or 0 for false), or -1 for verbs that don't refer to another sibling (for example, ALIGN_WITH_PARENT_BOTTOM)
    See Also:
      - `addRule(int)`
      - `addRule(int, int)`

  - ### getRules

    public int[] getRules(int layoutDirection)
    Retrieves a complete list of all supported rules, where the index is the rule verb, and the element value is the value specified, or "false" if it was never set. If there are relative rules defined (*_START / *_END), they will be resolved depending on the layout direction.
    Parameters:
      `layoutDirection` - the direction of the layout. Should be either `View.LAYOUT_DIRECTION_LTR` or `View.LAYOUT_DIRECTION_RTL`
    Returns:
      the supported rules
    See Also:
      - `addRule(int, int)`

  - ### getRules

    public int[] getRules()
    Retrieves a complete list of all supported rules, where the index is the rule verb, and the element value is the value specified, or "false" if it was never set. There will be no resolution of relative rules done.
    Returns:
      the supported rules
    See Also:
      - `addRule(int, int)`

  - ### resolveLayoutDirection

    public void resolveLayoutDirection(int layoutDirection)
    This will be called by `View.requestLayout()` to resolve layout parameters that are relative to the layout direction.

    After this method is called, any rules using layout-relative verbs (ex. `RelativeLayout.START_OF`) previously added via `addRule(int)` may only be accessed via their resolved absolute verbs (ex. `RelativeLayout.LEFT_OF`).

    Overrides:
      `resolveLayoutDirection` in class `ViewGroup.MarginLayoutParams`
    Parameters:
      `layoutDirection` - the direction of the layout
    See Also:
      - `View.LAYOUT_DIRECTION_LTR`
      - `View.LAYOUT_DIRECTION_RTL`