Class RelativeLayout.LayoutParams
- Enclosing class:
RelativeLayout
RelativeLayout
.
The relative layout containing the view uses the value of these layout parameters to
determine where to position the view on the screen. If the view is not contained
within a relative layout, these attributes are ignored.-
Field Summary
Modifier and TypeFieldDescriptionboolean
When true, uses the parent as the anchor if the anchor doesn't exist or if the anchor's visibility is GONE.Fields inherited from class icyllis.modernui.view.ViewGroup.MarginLayoutParams
bottomMargin, DEFAULT_MARGIN_RELATIVE, leftMargin, rightMargin, topMargin
Fields inherited from class icyllis.modernui.view.ViewGroup.LayoutParams
height, MATCH_PARENT, width, WRAP_CONTENT
-
Constructor Summary
ConstructorDescriptionLayoutParams
(int width, int height) LayoutParams
(ViewGroup.LayoutParams source) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.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 byView.requestLayout()
to resolve layout parameters that are relative to the layout direction.Methods inherited from class icyllis.modernui.view.ViewGroup.MarginLayoutParams
copyMarginsFrom, getLayoutDirection, getMarginEnd, getMarginStart, isLayoutRtl, isMarginRelative, onDebugDraw, setLayoutDirection, setMarginEnd, setMargins, setMarginsRelative, setMarginStart
-
Field Details
-
alignWithParent
public boolean alignWithParentWhen true, uses the parent as the anchor if the anchor doesn't exist or if the anchor's visibility is GONE.
-
-
Constructor Details
-
LayoutParams
public LayoutParams(int width, int height) -
LayoutParams
-
LayoutParams
-
LayoutParams
Copy constructor. Clones the width, height, margin values, gravity and rules of the source.- Parameters:
source
- the layout params to copy from.
-
-
Method Details
-
addRule
public void addRule(int verb) Adds a layout rule to be interpreted by the RelativeLayout.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, useaddRule(int, int)
.If the rule is relative to the layout direction (ex.
RelativeLayout.ALIGN_PARENT_START
), then the layout direction must be resolved usingresolveLayoutDirection(int)
before callinggetRule(int)
an absolute rule (ex.RelativeLayout.ALIGN_PARENT_LEFT
.- Parameters:
verb
- a layout verb, such asRelativeLayout.ALIGN_PARENT_LEFT
- See Also:
-
addRule
public void addRule(int verb, int subject) Adds a layout rule to be interpreted by the RelativeLayout.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 usingresolveLayoutDirection(int)
before callinggetRule(int)
with an absolute rule (ex.RelativeLayout.LEFT_OF
.- Parameters:
verb
- a layout verb, such asRelativeLayout.ALIGN_RIGHT
subject
- the ID of another view to use as an anchor, or a boolean value (represented asRelativeLayout.TRUE
for true or 0 for false)- See Also:
-
removeRule
public void removeRule(int verb) Removes a layout rule to be interpreted by the RelativeLayout.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 usingresolveLayoutDirection(int)
before before callinggetRule(int)
with an absolute rule (ex.RelativeLayout.LEFT_OF
.- Parameters:
verb
- One of the verbs defined byRelativeLayout
, such as ALIGN_WITH_PARENT_LEFT.- See Also:
-
getRule
public int getRule(int verb) Returns the layout rule associated with a specific verb.- Parameters:
verb
- one of the verbs defined byRelativeLayout
, such as ALIGN_WITH_PARENT_LEFT- Returns:
- the id of another view to use as an anchor, a boolean value
(represented as
RelativeLayout.TRUE
for true or 0 for false), or -1 for verbs that don't refer to another sibling (for example, ALIGN_WITH_PARENT_BOTTOM) - See Also:
-
getRules
public 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. If there are relative rules defined (*_START / *_END), they will be resolved depending on the layout direction.- Parameters:
layoutDirection
- the direction of the layout. Should be eitherView.LAYOUT_DIRECTION_LTR
orView.LAYOUT_DIRECTION_RTL
- Returns:
- the supported rules
- See Also:
-
getRules
public 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. There will be no resolution of relative rules done.- Returns:
- the supported rules
- See Also:
-
resolveLayoutDirection
public void resolveLayoutDirection(int layoutDirection) This will be called byView.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 viaaddRule(int)
may only be accessed via their resolved absolute verbs (ex.RelativeLayout.LEFT_OF
).- Overrides:
resolveLayoutDirection
in classViewGroup.MarginLayoutParams
- Parameters:
layoutDirection
- the direction of the layout- See Also:
-