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
Per-child layout information for layouts that support margins.
-
Field Summary
Modifier and TypeFieldDescriptionint
The bottom margin in pixels of the child.static final int
The default start and end margin.int
The left margin in pixels of the child.int
The right margin in pixels of the child.int
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
ConstructorDescriptionMarginLayoutParams
(int width, int height) Creates a new set of layout parameters with the specified width and height.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
int
Returns the layout direction.int
Returns the end margin in pixels.int
Returns the start margin in pixels.boolean
boolean
Check if margins are relative.void
onDebugDraw
(View view, Canvas canvas, Paint paint) void
resolveLayoutDirection
(int layoutDirection) This will be called byView.requestLayout()
.void
setLayoutDirection
(int layoutDirection) Set the layout directionvoid
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.
-
Field Details
-
leftMargin
public int leftMarginThe left margin in pixels of the child. Margin values should be positive. CallView.setLayoutParams(LayoutParams)
after reassigning a new value to this field. -
topMargin
public int topMarginThe top margin in pixels of the child. Margin values should be positive. CallView.setLayoutParams(LayoutParams)
after reassigning a new value to this field. -
rightMargin
public int rightMarginThe right margin in pixels of the child. Margin values should be positive. CallView.setLayoutParams(LayoutParams)
after reassigning a new value to this field. -
bottomMargin
public int bottomMarginThe bottom margin in pixels of the child. Margin values should be positive. CallView.setLayoutParams(LayoutParams)
after reassigning a new value to this field. -
DEFAULT_MARGIN_RELATIVE
@Internal public static final int DEFAULT_MARGIN_RELATIVEThe default start and end margin.- See Also:
-
-
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, eitherViewGroup.LayoutParams.WRAP_CONTENT
,ViewGroup.LayoutParams.MATCH_PARENT
, or a size in pixelsheight
- the height, eitherViewGroup.LayoutParams.WRAP_CONTENT
,ViewGroup.LayoutParams.MATCH_PARENT
, or a size in pixels
-
MarginLayoutParams
Copy constructor. Clones the width, height and margin values of the source.- Parameters:
source
- The layout params to copy from.
-
MarginLayoutParams
-
-
Method Details
-
copyMarginsFrom
-
setMargins
public void setMargins(int left, int top, int right, int bottom) Sets the margins, in pixels. A call toView.requestLayout()
needs to be done so that the new margins are taken into account. Left and right margins may be overridden byView.requestLayout()
depending on layout direction. Margin values should be positive.- Parameters:
left
- the left margin sizetop
- the top margin sizeright
- the right margin sizebottom
- the bottom margin size
-
setMarginsRelative
public void setMarginsRelative(int start, int top, int end, int bottom) Sets the relative margins, in pixels. A call toView.requestLayout()
needs to be done so that the new relative margins are taken into account. Left and right margins may be overridden byView.requestLayout()
depending on layout direction. Margin values should be positive.- Parameters:
start
- the start margin sizetop
- the top margin sizeend
- the right margin sizebottom
- 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 eitherView.LAYOUT_DIRECTION_LTR
orView.LAYOUT_DIRECTION_RTL
.
-
getLayoutDirection
public int getLayoutDirection()Returns the layout direction. Can be eitherView.LAYOUT_DIRECTION_LTR
orView.LAYOUT_DIRECTION_RTL
.- Returns:
- the layout direction.
-
resolveLayoutDirection
public void resolveLayoutDirection(int layoutDirection) This will be called byView.requestLayout()
. Left and Right margins may be overridden depending on layout direction.- Overrides:
resolveLayoutDirection
in classViewGroup.LayoutParams
- Parameters:
layoutDirection
- the direction of the layout- See Also:
-
isLayoutRtl
@Internal public boolean isLayoutRtl() -
onDebugDraw
-