public static class RelativeLayout.LayoutParams extends ViewGroup.MarginLayoutParams
Modifier and Type | Field and 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.
|
bottomMargin, DEFAULT_MARGIN_RELATIVE, leftMargin, rightMargin, topMargin
FILL_PARENT, height, layoutAnimationParameters, MATCH_PARENT, width, WRAP_CONTENT
Constructor and Description |
---|
LayoutParams(Context c,
AttributeSet attrs) |
LayoutParams(int w,
int h) |
LayoutParams(RelativeLayout.LayoutParams source)
Copy constructor.
|
LayoutParams(ViewGroup.LayoutParams source) |
LayoutParams(ViewGroup.MarginLayoutParams source) |
Modifier and Type | Method and 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.
|
String |
debug(String output)
Returns a String representation of this set of layout parameters.
|
protected void |
encodeProperties(ViewHierarchyEncoder encoder) |
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. |
copyMarginsFrom, getLayoutDirection, getMarginEnd, getMarginStart, isLayoutRtl, isMarginRelative, onDebugDraw, setLayoutDirection, setMarginEnd, setMargins, setMarginsRelative, setMarginStart
setBaseAttributes, sizeToString
public boolean alignWithParent
public LayoutParams(Context c, AttributeSet attrs)
public LayoutParams(int w, int h)
public LayoutParams(ViewGroup.LayoutParams source)
public LayoutParams(ViewGroup.MarginLayoutParams source)
public LayoutParams(RelativeLayout.LayoutParams source)
source
- The layout params to copy from.public String debug(String output)
ViewGroup.LayoutParams
debug
in class ViewGroup.LayoutParams
output
- the String to prepend to the internal representationpublic void addRule(int verb)
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
.
verb
- a layout verb, such as RelativeLayout.ALIGN_PARENT_LEFT
addRule(int, int)
,
removeRule(int)
,
getRule(int)
public void addRule(int verb, int subject)
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
.
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)addRule(int)
,
removeRule(int)
,
getRule(int)
public void removeRule(int verb)
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
.
verb
- One of the verbs defined by
RelativeLayout
, such as
ALIGN_WITH_PARENT_LEFT.addRule(int)
,
addRule(int, int)
,
getRule(int)
public int getRule(int verb)
verb
- one of the verbs defined by RelativeLayout
, such
as ALIGN_WITH_PARENT_LEFTRelativeLayout.TRUE
for true
or 0 for false), or -1 for verbs that don't refer to another
sibling (for example, ALIGN_WITH_PARENT_BOTTOM)addRule(int)
,
addRule(int, int)
public int[] getRules(int layoutDirection)
layoutDirection
- the direction of the layout.
Should be either View.LAYOUT_DIRECTION_LTR
or View.LAYOUT_DIRECTION_RTL
addRule(int, int)
public int[] getRules()
addRule(int, int)
public void resolveLayoutDirection(int layoutDirection)
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
).
resolveLayoutDirection
in class ViewGroup.MarginLayoutParams
layoutDirection
- the direction of the layout
View.LAYOUT_DIRECTION_LTR
View.LAYOUT_DIRECTION_RTL
protected void encodeProperties(ViewHierarchyEncoder encoder)
encodeProperties
in class ViewGroup.MarginLayoutParams