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 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:
  • Constructor Details

  • 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:
    • isLayoutRtl

      @Internal public boolean isLayoutRtl()
    • onDebugDraw

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