Package icyllis.modernui.view

# Class ViewGroup.MarginLayoutParams

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

Direct Known Subclasses:
  `CoordinatorLayout.LayoutParams`, `FrameLayout.LayoutParams`, `GridLayout.LayoutParams`, `LinearLayout.LayoutParams`, `RelativeLayout.LayoutParams`

Enclosing class:
  `ViewGroup`

public static class ViewGroup.MarginLayoutParams extends ViewGroup.LayoutParams
Per-child layout information for layouts that support margins.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `int`
  `bottomMargin`
  The bottom margin in pixels of the child.
  `static final int`
  `DEFAULT_MARGIN_RELATIVE`
  The default start and end margin.
  `int`
  `leftMargin`
  The left margin in pixels of the child.
  `int`
  `rightMargin`
  The right margin in pixels of the child.
  `int`
  `topMargin`
  The top margin in pixels of the child.

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

  `height, MATCH_PARENT, width, WRAP_CONTENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MarginLayoutParams(int width, int height)`
  Creates a new set of layout parameters with the specified width and height.
  `MarginLayoutParams(ViewGroup.LayoutParams source)`
  `MarginLayoutParams(ViewGroup.MarginLayoutParams source)`
  Copy constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final void`
  `copyMarginsFrom(ViewGroup.MarginLayoutParams source)`
  `int`
  `getLayoutDirection()`
  Returns the layout direction.
  `int`
  `getMarginEnd()`
  Returns the end margin in pixels.
  `int`
  `getMarginStart()`
  Returns the start margin in pixels.
  `boolean`
  `isLayoutRtl()`
  `boolean`
  `isMarginRelative()`
  Check if margins are relative.
  `void`
  `onDebugDraw(View view, Canvas canvas, Paint paint)`
  `void`
  `resolveLayoutDirection(int layoutDirection)`
  This will be called by `View.requestLayout()`.
  `void`
  `setLayoutDirection(int layoutDirection)`
  Set the layout direction
  `void`
  `setMarginEnd(int end)`
  Sets the relative end margin.
  `void`
  `setMargins(int left, int top, int right, int bottom)`
  Sets the margins, in pixels.
  `void`
  `setMarginsRelative(int start, int top, int end, int bottom)`
  Sets the relative margins, in pixels.
  `void`
  `setMarginStart(int start)`
  Sets the relative start margin.

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

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

- ## Field Details

  - ### leftMargin

    public int leftMargin
    The left margin in pixels of the child. Margin values should be positive. Call `View.setLayoutParams(LayoutParams)` after reassigning a new value to this field.

  - ### topMargin

    public int topMargin
    The top margin in pixels of the child. Margin values should be positive. Call `View.setLayoutParams(LayoutParams)` after reassigning a new value to this field.

  - ### rightMargin

    public int rightMargin
    The right margin in pixels of the child. Margin values should be positive. Call `View.setLayoutParams(LayoutParams)` after reassigning a new value to this field.

  - ### bottomMargin

    public int bottomMargin
    The bottom margin in pixels of the child. Margin values should be positive. Call `View.setLayoutParams(LayoutParams)` after reassigning a new value to this field.

  - ### DEFAULT_MARGIN_RELATIVE

    @Internal public static final int DEFAULT_MARGIN_RELATIVE
    The default start and end margin.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### MarginLayoutParams

    public MarginLayoutParams(int width, int height)
    Creates a new set of layout parameters with the specified width and height.
    Parameters:
      `width` - the width, either `ViewGroup.LayoutParams.WRAP_CONTENT`, `ViewGroup.LayoutParams.MATCH_PARENT`, or a size in pixels
      `height` - the height, either `ViewGroup.LayoutParams.WRAP_CONTENT`, `ViewGroup.LayoutParams.MATCH_PARENT`, or a size in pixels

  - ### MarginLayoutParams

    public MarginLayoutParams(@NonNull ViewGroup.MarginLayoutParams source)
    Copy constructor. Clones the width, height and margin values of the source.
    Parameters:
      `source` - The layout params to copy from.

  - ### MarginLayoutParams

    public MarginLayoutParams(ViewGroup.LayoutParams source)

- ## Method Details

  - ### copyMarginsFrom

    @Internal public final void copyMarginsFrom(@NonNull ViewGroup.MarginLayoutParams source)

  - ### setMargins

    public void setMargins(int left, int top, int right, int bottom)
    Sets the margins, in pixels. A call to `View.requestLayout()` needs to be done so that the new margins are taken into account. Left and right margins may be overridden by `View.requestLayout()` depending on layout direction. Margin values should be positive.
    Parameters:
      `left` - the left margin size
      `top` - the top margin size
      `right` - the right margin size
      `bottom` - the bottom margin size

  - ### setMarginsRelative

    public void setMarginsRelative(int start, int top, int end, int bottom)
    Sets the relative margins, in pixels. A call to `View.requestLayout()` needs to be done so that the new relative margins are taken into account. Left and right margins may be overridden by `View.requestLayout()` depending on layout direction. Margin values should be positive.
    Parameters:
      `start` - the start margin size
      `top` - the top margin size
      `end` - the right margin size
      `bottom` - the bottom margin size

  - ### setMarginStart

    public void setMarginStart(int start)
    Sets the relative start margin. Margin values should be positive.
    Parameters:
      `start` - the start margin size

  - ### getMarginStart

    public int getMarginStart()
    Returns the start margin in pixels.
    Returns:
      the start margin in pixels.

  - ### setMarginEnd

    public void setMarginEnd(int end)
    Sets the relative end margin. Margin values should be positive.
    Parameters:
      `end` - the end margin size

  - ### getMarginEnd

    public int getMarginEnd()
    Returns the end margin in pixels.
    Returns:
      the end margin in pixels.

  - ### isMarginRelative

    public boolean isMarginRelative()
    Check if margins are relative.
    Returns:
      true if either marginStart or marginEnd has been set.

  - ### setLayoutDirection

    public void setLayoutDirection(int layoutDirection)
    Set the layout direction
    Parameters:
      `layoutDirection` - the layout direction. Should be either `View.LAYOUT_DIRECTION_LTR` or `View.LAYOUT_DIRECTION_RTL`.

  - ### getLayoutDirection

    public int getLayoutDirection()
    Returns the layout direction. Can be either `View.LAYOUT_DIRECTION_LTR` or `View.LAYOUT_DIRECTION_RTL`.
    Returns:
      the layout direction.

  - ### resolveLayoutDirection

    public void resolveLayoutDirection(int layoutDirection)
    This will be called by `View.requestLayout()`. Left and Right margins may be overridden depending on layout direction.
    Overrides:
      `resolveLayoutDirection` in class `ViewGroup.LayoutParams`
    Parameters:
      `layoutDirection` - the direction of the layout
    See Also:
      - `View.LAYOUT_DIRECTION_LTR`
      - `View.LAYOUT_DIRECTION_RTL`

  - ### isLayoutRtl

    @Internal public boolean isLayoutRtl()

  - ### onDebugDraw

    @Internal public void onDebugDraw(View view, Canvas canvas, Paint paint)