public static class ViewGroup.MarginLayoutParams extends ViewGroup.LayoutParams
ViewGroup Margin Layout Attributes
for a list of all child view attributes that this class supports.Modifier and Type | Field and Description |
---|---|
int |
bottomMargin
The bottom margin in pixels of the child.
|
static int |
DEFAULT_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.
|
FILL_PARENT, height, layoutAnimationParameters, MATCH_PARENT, width, WRAP_CONTENT
Constructor and Description |
---|
ViewGroup.MarginLayoutParams(Context c,
AttributeSet attrs)
Creates a new set of layout parameters.
|
ViewGroup.MarginLayoutParams(int width,
int height) |
ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams source) |
ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams source)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getLayoutDirection()
Retuns 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)
Use
canvas to draw suitable debugging annotations for these LayoutParameters. |
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.
|
debug, setBaseAttributes, sizeToString
public int leftMargin
ViewGroup#setLayoutParams(LayoutParams)
after reassigning a new value
to this field.public int topMargin
ViewGroup#setLayoutParams(LayoutParams)
after reassigning a new value
to this field.public int rightMargin
ViewGroup#setLayoutParams(LayoutParams)
after reassigning a new value
to this field.public int bottomMargin
ViewGroup#setLayoutParams(LayoutParams)
after reassigning a new value
to this field.public static final int DEFAULT_RELATIVE
public ViewGroup.MarginLayoutParams(Context c, AttributeSet attrs)
c
- the application environmentattrs
- the set of attributes from which to extract the layout
parameters' valuespublic ViewGroup.MarginLayoutParams(int width, int height)
public ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams source)
source
- The layout params to copy from.public ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams source)
public void setMargins(int left, int top, int right, int bottom)
View.requestLayout()
needs
to be done so that the new margins are taken into account. Left and right margins may be
overriden by View.requestLayout()
depending on layout direction.left
- the left margin sizetop
- the top margin sizeright
- the right margin sizebottom
- the bottom margin sizepublic void setMarginsRelative(int start, int top, int end, int bottom)
View.requestLayout()
needs to be done so that the new relative margins are taken into account. Left and right
margins may be overriden by View.requestLayout()
depending on layout
direction.start
- the start margin sizetop
- the top margin sizeend
- the right margin sizebottom
- the bottom margin sizepublic void setMarginStart(int start)
start
- the start margin sizepublic int getMarginStart()
public void setMarginEnd(int end)
end
- the end margin sizepublic int getMarginEnd()
public boolean isMarginRelative()
public void setLayoutDirection(int layoutDirection)
layoutDirection
- the layout direction.
Should be either View.LAYOUT_DIRECTION_LTR
or View.LAYOUT_DIRECTION_RTL
.public int getLayoutDirection()
View.LAYOUT_DIRECTION_LTR
or
View.LAYOUT_DIRECTION_RTL
.public void resolveLayoutDirection(int layoutDirection)
View.requestLayout()
. Left and Right margins
may be overridden depending on layout direction.resolveLayoutDirection
in class ViewGroup.LayoutParams
layoutDirection
- the direction of the layout
View.LAYOUT_DIRECTION_LTR
View.LAYOUT_DIRECTION_RTL
public boolean isLayoutRtl()
public void onDebugDraw(View view, Canvas canvas)
ViewGroup.LayoutParams
canvas
to draw suitable debugging annotations for these LayoutParameters.onDebugDraw
in class ViewGroup.LayoutParams
view
- the view that contains these layout parameterscanvas
- the canvas on which to draw