T
- the type of this builder. Required to ensure methods defined here in the abstract
class correctly return the type of the concrete subclass.public abstract static class Component.Builder<T extends Component.Builder<T>> extends Object implements Cloneable
Modifier and Type | Field and Description |
---|---|
protected ResourceResolver |
mResourceResolver |
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
T |
accessibilityHeading(boolean isHeading)
Ports
ViewCompat into components world. |
T |
accessibilityRole(String role) |
T |
accessibilityRoleDescription(CharSequence roleDescription) |
T |
accessibilityRoleDescription(int stringId) |
T |
accessibilityRoleDescription(int stringId,
Object... formatArgs) |
T |
alignSelf(YogaAlign alignSelf)
Controls how a child aligns in the cross direction, overriding the alignItems of the parent.
|
T |
alpha(DynamicValue<Float> value)
Links a
DynamicValue object ot the alpha value for this Component |
T |
alpha(float alpha)
Sets the alpha (opacity) of this component.
|
T |
aspectRatio(float aspectRatio)
Defined as the ratio between the width and the height of a node.
|
T |
background(Drawable background)
Set the background of this component.
|
T |
backgroundAttr(int resId) |
T |
backgroundAttr(int resId,
int defaultResId) |
T |
backgroundColor(DynamicValue<Integer> value)
Links a
DynamicValue object to the background color value for this Component |
T |
backgroundColor(int backgroundColor) |
T |
backgroundRes(int resId) |
T |
border(Border border) |
abstract Component |
build() |
protected static void |
checkArgs(int requiredPropsCount,
BitSet required,
String[] requiredPropsNames)
Checks that all the required props are supplied, and if not throws a useful exception
|
T |
clickable(boolean isClickable) |
T |
clickHandler(EventHandler<ClickEvent> clickHandler) |
T |
clipChildren(boolean clipChildren)
Ports
ViewGroup into components world. |
T |
clipToOutline(boolean clipToOutline) |
Component.Builder |
clone() |
T |
contentDescription(CharSequence contentDescription) |
T |
contentDescription(int stringId) |
T |
contentDescription(int stringId,
Object... formatArgs) |
T |
dispatchPopulateAccessibilityEventHandler(EventHandler<DispatchPopulateAccessibilityEventEvent> dispatchPopulateAccessibilityEventHandler) |
T |
duplicateParentState(boolean duplicateParentState)
If true, component duplicates its drawable state (focused, pressed, etc.) from the direct
parent.
|
T |
enabled(boolean isEnabled) |
T |
flex(float flex)
Sets flexGrow, flexShrink, and flexBasis at the same time.
|
T |
flexBasisAttr(int resId) |
T |
flexBasisAttr(int resId,
int defaultResId) |
T |
flexBasisDip(float flexBasis) |
T |
flexBasisPercent(float percent) |
T |
flexBasisPx(int flexBasis)
The FlexBasis property is an axis-independent way of providing the default size of an item on
the main axis.
|
T |
flexBasisRes(int resId) |
T |
flexGrow(float flexGrow)
If the sum of childrens' main axis dimensions is less than the minimum size, how much should
this component grow? This value represents the "flex grow factor" and determines how much
this component should grow along the main axis in relation to any other flexible children.
|
T |
flexShrink(float flexShrink)
The FlexShrink property describes how to shrink children along the main axis in the case that
the total size of the children overflow the size of the container on the main axis.
|
T |
focusable(boolean isFocusable) |
T |
focusChangeHandler(EventHandler<FocusChangedEvent> focusChangeHandler) |
T |
focusedHandler(EventHandler<FocusedVisibleEvent> focusedHandler) |
T |
foreground(Drawable foreground)
Set the foreground of this component.
|
T |
foregroundAttr(int resId) |
T |
foregroundAttr(int resId,
int defaultResId) |
T |
foregroundColor(int foregroundColor) |
T |
foregroundRes(int resId) |
T |
fullImpressionHandler(EventHandler<FullImpressionVisibleEvent> fullImpressionHandler) |
ComponentContext |
getContext() |
abstract T |
getThis() |
T |
handle(Handle handle) |
boolean |
hasBackgroundSet() |
boolean |
hasClickHandlerSet() |
T |
heightAttr(int resId) |
T |
heightAttr(int resId,
int defaultResId) |
T |
heightDip(float height) |
T |
heightPercent(float percent)
Sets the height of the Component to be a percentage of its parent's height.
|
T |
heightPx(int height)
Specifies the height of the element's content area.
|
T |
heightRes(int resId) |
T |
importantForAccessibility(int importantForAccessibility) |
protected void |
init(ComponentContext c,
int defStyleAttr,
int defStyleRes,
Component component) |
T |
interceptTouchHandler(EventHandler<InterceptTouchEvent> interceptTouchHandler) |
T |
invisibleHandler(EventHandler<InvisibleEvent> invisibleHandler) |
T |
isReferenceBaseline(boolean isReferenceBaseline) |
T |
key(String key)
Set a key on the component that is local to its parent.
|
T |
layoutDirection(YogaDirection layoutDirection)
The RTL/LTR direction of components and text.
|
T |
longClickHandler(EventHandler<LongClickEvent> longClickHandler) |
T |
marginAttr(YogaEdge edge,
int resId) |
T |
marginAttr(YogaEdge edge,
int resId,
int defaultResId) |
T |
marginAuto(YogaEdge edge) |
T |
marginDip(YogaEdge edge,
float margin) |
T |
marginPercent(YogaEdge edge,
float percent) |
T |
marginPx(YogaEdge edge,
int margin)
Effects the spacing around the outside of a node.
|
T |
marginRes(YogaEdge edge,
int resId) |
T |
maxHeightAttr(int resId) |
T |
maxHeightAttr(int resId,
int defaultResId) |
T |
maxHeightDip(float maxHeight) |
T |
maxHeightPercent(float percent) |
T |
maxHeightPx(int maxHeight) |
T |
maxHeightRes(int resId) |
T |
maxWidthAttr(int resId) |
T |
maxWidthAttr(int resId,
int defaultResId) |
T |
maxWidthDip(float maxWidth) |
T |
maxWidthPercent(float percent) |
T |
maxWidthPx(int maxWidth) |
T |
maxWidthRes(int resId) |
T |
minHeightAttr(int resId) |
T |
minHeightAttr(int resId,
int defaultResId) |
T |
minHeightDip(float minHeight) |
T |
minHeightPercent(float percent) |
T |
minHeightPx(int minHeight) |
T |
minHeightRes(int resId) |
T |
minWidthAttr(int resId) |
T |
minWidthAttr(int resId,
int defaultResId) |
T |
minWidthDip(float minWidth) |
T |
minWidthPercent(float percent) |
T |
minWidthPx(int minWidth)
This property has higher priority than all other properties and will always be respected.
|
T |
minWidthRes(int resId) |
T |
onInitializeAccessibilityEventHandler(EventHandler<OnInitializeAccessibilityEventEvent> onInitializeAccessibilityEventHandler) |
T |
onInitializeAccessibilityNodeInfoHandler(EventHandler<OnInitializeAccessibilityNodeInfoEvent> onInitializeAccessibilityNodeInfoHandler) |
T |
onPopulateAccessibilityEventHandler(EventHandler<OnPopulateAccessibilityEventEvent> onPopulateAccessibilityEventHandler) |
T |
onRequestSendAccessibilityEventHandler(EventHandler<OnRequestSendAccessibilityEventEvent> onRequestSendAccessibilityEventHandler) |
T |
outlineProvider(ViewOutlineProvider outlineProvider) |
T |
paddingAttr(YogaEdge edge,
int resId) |
T |
paddingAttr(YogaEdge edge,
int resId,
int defaultResId) |
T |
paddingDip(YogaEdge edge,
float padding) |
T |
paddingPercent(YogaEdge edge,
float percent) |
T |
paddingPx(YogaEdge edge,
int padding)
Affects the size of the node it is applied to.
|
T |
paddingRes(YogaEdge edge,
int resId) |
T |
performAccessibilityActionHandler(EventHandler<PerformAccessibilityActionEvent> performAccessibilityActionHandler) |
T |
positionAttr(YogaEdge edge,
int resId) |
T |
positionAttr(YogaEdge edge,
int resId,
int defaultResId) |
T |
positionDip(YogaEdge edge,
float position) |
T |
positionPercent(YogaEdge edge,
float percent) |
T |
positionPx(YogaEdge edge,
int position)
When used in combination with
positionType(com.facebook.yoga.YogaPositionType) of YogaPositionType.ABSOLUTE ,
allows the component to specify how it should be positioned within its parent. |
T |
positionRes(YogaEdge edge,
int resId) |
T |
positionType(YogaPositionType positionType)
Controls how this component will be positioned within its parent.
|
T |
rotation(DynamicValue<Float> rotation)
Links a
DynamicValue object to the rotation value for this Component |
T |
rotation(float rotation)
Sets the degree that this component is rotated around the pivot point.
|
T |
rotationX(float rotationX)
Sets the degree that this component is rotated around the horizontal axis through the pivot
point.
|
T |
rotationY(float rotationY)
Sets the degree that this component is rotated around the vertical axis through the pivot
point.
|
T |
scale(float scale)
Sets the scale (scaleX and scaleY) on this component.
|
T |
scaleX(DynamicValue<Float> value)
Links a
DynamicValue object to the scaleX value for this Component |
T |
scaleY(DynamicValue<Float> value)
Links a
DynamicValue object to the scaleY value for this Component |
T |
selected(boolean isSelected) |
T |
sendAccessibilityEventHandler(EventHandler<SendAccessibilityEventEvent> sendAccessibilityEventHandler) |
T |
sendAccessibilityEventUncheckedHandler(EventHandler<SendAccessibilityEventUncheckedEvent> sendAccessibilityEventUncheckedHandler) |
protected abstract void |
setComponent(Component component) |
T |
shadowElevation(DynamicValue<Float> value)
Links a
DynamicValue object to the elevation value for this Component |
T |
shadowElevationAttr(int resId) |
T |
shadowElevationAttr(int resId,
int defaultResId) |
T |
shadowElevationDip(float shadowElevation) |
T |
shadowElevationPx(float shadowElevation)
Shadow elevation and outline provider methods are only functional on
Build.VERSION_CODES and above. |
T |
shadowElevationRes(int resId) |
T |
stateListAnimator(StateListAnimator stateListAnimator)
Ports
View
into components world. |
T |
stateListAnimatorRes(int resId)
Ports
View
into components world. |
T |
testKey(String testKey) |
T |
touchExpansionAttr(YogaEdge edge,
int resId) |
T |
touchExpansionAttr(YogaEdge edge,
int resId,
int defaultResId) |
T |
touchExpansionDip(YogaEdge edge,
float touchExpansion) |
T |
touchExpansionPx(YogaEdge edge,
int touchExpansion) |
T |
touchExpansionRes(YogaEdge edge,
int resId) |
T |
touchHandler(EventHandler<TouchEvent> touchHandler) |
T |
transitionKey(String key) |
T |
transitionKeyType(Transition.TransitionKeyType type) |
T |
translationX(DynamicValue<Float> value)
Links a
DynamicValue object to the translationX value for this Component |
T |
translationY(DynamicValue<Float> value)
Links a
DynamicValue object to the translationY value for this Component |
T |
unfocusedHandler(EventHandler<UnfocusedVisibleEvent> unfocusedHandler) |
T |
useHeightAsBaseline(boolean useHeightAsBaseline)
When set to true, overrides the default behaviour of baseline calculation and uses height of
component as baseline.
|
T |
viewTag(Object viewTag) |
T |
viewTags(<any> viewTags) |
T |
visibilityChangedHandler(EventHandler<VisibilityChangedEvent> visibilityChangedHandler) |
T |
visibleHandler(EventHandler<VisibleEvent> visibleHandler) |
T |
visibleHeightRatio(float visibleHeightRatio) |
T |
visibleWidthRatio(float visibleWidthRatio) |
T |
widthAttr(int resId) |
T |
widthAttr(int resId,
int defaultResId) |
T |
widthDip(float width) |
T |
widthPercent(float percent)
Sets the width of the Component to be a percentage of its parent's width.
|
T |
widthPx(int width)
Specifies the width of the element's content area.
|
T |
widthRes(int resId) |
T |
wrapInView() |
protected ResourceResolver mResourceResolver
public abstract Component build()
public abstract T getThis()
public Component.Builder clone()
protected abstract void setComponent(Component component)
public T accessibilityHeading(boolean isHeading)
ViewCompat
into components world. However,
since the aforementioned ViewCompat's method is available only on API 19 and above, calling
this method on lower APIs will have no effect. On the legit versions, on the other hand,
calling this method will lead to the component being treated as a heading. The
AccessibilityHeading property allows accessibility services to help users navigate directly
from one heading to the next. See https://developer.android.com/reference/android/
support/v4/view/accessibility/AccessibilityNodeInfoCompat#setheading for more
information.
Default: false
public T accessibilityRoleDescription(CharSequence roleDescription)
public T accessibilityRoleDescription(int stringId)
public T accessibilityRoleDescription(int stringId, Object... formatArgs)
public T alignSelf(YogaAlign alignSelf)
Default: YogaAlign.AUTO
public T alpha(float alpha)
public T alpha(DynamicValue<Float> value)
DynamicValue
object ot the alpha value for this Componentvalue
- controller for the alpha valuepublic T aspectRatio(float aspectRatio)
public T background(Drawable background)
ComparableDrawable
for more efficient diffing while when drawables are remounted or updated.ComparableDrawable
public T backgroundAttr(int resId, int defaultResId)
public T backgroundAttr(int resId)
public T backgroundColor(int backgroundColor)
public T backgroundColor(DynamicValue<Integer> value)
DynamicValue
object to the background color value for this Componentvalue
- controller for the background color valuepublic T backgroundRes(int resId)
public T clickHandler(EventHandler<ClickEvent> clickHandler)
public T clickable(boolean isClickable)
public T clipChildren(boolean clipChildren)
ViewGroup
into components world. However,
there is no guarantee that child of this component would be translated into direct view child
in the resulting view hierarchy.clipChildren
- true to clip children to their bounds. False allows each child to draw
outside of its own bounds within the parent, it doesn't allow children to draw outside of
the parent itself.public T clipToOutline(boolean clipToOutline)
public T contentDescription(CharSequence contentDescription)
public T contentDescription(int stringId)
public T dispatchPopulateAccessibilityEventHandler(EventHandler<DispatchPopulateAccessibilityEventEvent> dispatchPopulateAccessibilityEventHandler)
public T duplicateParentState(boolean duplicateParentState)
In the following example, when Row
gets pressed state, its child OtherStatefulDrawable
will get that pressed state within itself, too:
Row.create(c)
.drawable(stateListDrawable)
.clickable(true)
.child(
OtherStatefulDrawable.create(c)
.duplicateParentState(true))
public T enabled(boolean isEnabled)
public T flex(float flex)
When flex is a positive number, it makes the component flexible and it will be sized proportional to its flex value. So a component with flex set to 2 will take twice the space as a component with flex set to 1.
When flex is 0, the component is sized according to width and height and it is inflexible.
When flex is -1, the component is normally sized according width and height. However, if there's not enough space, the component will shrink to its minWidth and minHeight.
See https://yogalayout.com/docs/flex for more information.
Default: 0
public T flexBasisAttr(int resId, int defaultResId)
flexBasisPx(int)
public T flexBasisAttr(int resId)
flexBasisPx(int)
public T flexBasisDip(float flexBasis)
flexBasisPx(int)
public T flexBasisPercent(float percent)
percent
- a value between 0 and 100.flexBasisPx(int)
public T flexBasisPx(int flexBasis)
Default: 0
public T flexBasisRes(int resId)
flexBasisPx(int)
public T flexGrow(float flexGrow)
Default: 0
public T flexShrink(float flexShrink)
Default: 1
public T focusChangeHandler(EventHandler<FocusChangedEvent> focusChangeHandler)
public T focusable(boolean isFocusable)
public T focusedHandler(EventHandler<FocusedVisibleEvent> focusedHandler)
public T foreground(Drawable foreground)
ComparableDrawable
for more efficient diffing while when drawables are remounted or updated.
If the drawable does not extend ComparableDrawable
then create a new class which
extends ComparableDrawable
and implement the ComparableDrawable.isEquivalentTo(ComparableDrawable)
.ComparableDrawable
public T foregroundAttr(int resId, int defaultResId)
public T foregroundAttr(int resId)
public T foregroundColor(int foregroundColor)
public T foregroundRes(int resId)
public T fullImpressionHandler(EventHandler<FullImpressionVisibleEvent> fullImpressionHandler)
public ComponentContext getContext()
ComponentContext
for this Component.Builder
, useful for Kotlin DSL. Will be
null if the Builder was already used to build()
a component.public boolean hasBackgroundSet()
public boolean hasClickHandlerSet()
public T heightAttr(int resId, int defaultResId)
heightPx(int)
public T heightAttr(int resId)
heightPx(int)
public T heightDip(float height)
heightPx(int)
public T heightPercent(float percent)
percent
- a value between 0 and 100.heightPx(int)
public T heightPx(int height)
public T heightRes(int resId)
heightPx(int)
public T importantForAccessibility(int importantForAccessibility)
public T interceptTouchHandler(EventHandler<InterceptTouchEvent> interceptTouchHandler)
public T invisibleHandler(EventHandler<InvisibleEvent> invisibleHandler)
public T isReferenceBaseline(boolean isReferenceBaseline)
public T layoutDirection(YogaDirection layoutDirection)
YogaEdge.START
and
YogaEdge.END
will resolve to the left or right side, among other things. INHERIT
indicates this setting will be inherited from this component's parent.
Default: YogaDirection.INHERIT
public T longClickHandler(EventHandler<LongClickEvent> longClickHandler)
public T marginPercent(YogaEdge edge, float percent)
percent
- a value between 0 and 100.marginPx(com.facebook.yoga.YogaEdge, int)
public T marginPx(YogaEdge edge, int margin)
public T maxHeightAttr(int resId, int defaultResId)
minWidthPx(int)
public T maxHeightAttr(int resId)
minWidthPx(int)
public T maxHeightDip(float maxHeight)
minWidthPx(int)
public T maxHeightPercent(float percent)
percent
- a value between 0 and 100.minWidthPx(int)
public T maxHeightPx(int maxHeight)
minWidthPx(int)
public T maxHeightRes(int resId)
minWidthPx(int)
public T maxWidthAttr(int resId, int defaultResId)
minWidthPx(int)
public T maxWidthAttr(int resId)
minWidthPx(int)
public T maxWidthDip(float maxWidth)
minWidthPx(int)
public T maxWidthPercent(float percent)
percent
- a value between 0 and 100.minWidthPx(int)
public T maxWidthPx(int maxWidth)
minWidthPx(int)
public T maxWidthRes(int resId)
minWidthPx(int)
public T minHeightAttr(int resId, int defaultResId)
minWidthPx(int)
public T minHeightAttr(int resId)
minWidthPx(int)
public T minHeightDip(float minHeight)
minWidthPx(int)
public T minHeightPercent(float percent)
percent
- a value between 0 and 100.minWidthPx(int)
public T minHeightPx(int minHeight)
minWidthPx(int)
public T minHeightRes(int resId)
minWidthPx(int)
public T minWidthAttr(int resId, int defaultResId)
minWidthPx(int)
public T minWidthAttr(int resId)
minWidthPx(int)
public T minWidthDip(float minWidth)
minWidthPx(int)
public T minWidthPercent(float percent)
percent
- a value between 0 and 100.minWidthPx(int)
public T minWidthPx(int minWidth)
public T minWidthRes(int resId)
minWidthPx(int)
public T onInitializeAccessibilityEventHandler(EventHandler<OnInitializeAccessibilityEventEvent> onInitializeAccessibilityEventHandler)
public T onInitializeAccessibilityNodeInfoHandler(EventHandler<OnInitializeAccessibilityNodeInfoEvent> onInitializeAccessibilityNodeInfoHandler)
public T onPopulateAccessibilityEventHandler(EventHandler<OnPopulateAccessibilityEventEvent> onPopulateAccessibilityEventHandler)
public T onRequestSendAccessibilityEventHandler(EventHandler<OnRequestSendAccessibilityEventEvent> onRequestSendAccessibilityEventHandler)
public T outlineProvider(ViewOutlineProvider outlineProvider)
public T paddingPercent(YogaEdge edge, float percent)
percent
- a value between 0 and 100.paddingPx(com.facebook.yoga.YogaEdge, int)
public T paddingPx(YogaEdge edge, int padding)
public T performAccessibilityActionHandler(EventHandler<PerformAccessibilityActionEvent> performAccessibilityActionHandler)
public T positionPercent(YogaEdge edge, float percent)
percent
- a value between 0 and 100.positionPx(com.facebook.yoga.YogaEdge, int)
public T positionPx(YogaEdge edge, int position)
positionType(com.facebook.yoga.YogaPositionType)
of YogaPositionType.ABSOLUTE
,
allows the component to specify how it should be positioned within its parent. See https://yogalayout.com/docs/absolute-relative-layout
for more information.public T positionType(YogaPositionType positionType)
Default: YogaPositionType.RELATIVE
public T rotation(float rotation)
public T rotation(DynamicValue<Float> rotation)
DynamicValue
object to the rotation value for this Componentvalue
- controller for the rotation valuepublic T rotationX(float rotationX)
public T rotationY(float rotationY)
public T scale(float scale)
public T scaleX(DynamicValue<Float> value)
DynamicValue
object to the scaleX value for this Componentvalue
- controller for the scaleX valuepublic T scaleY(DynamicValue<Float> value)
DynamicValue
object to the scaleY value for this Componentvalue
- controller for the scaleY valuepublic T selected(boolean isSelected)
public T sendAccessibilityEventHandler(EventHandler<SendAccessibilityEventEvent> sendAccessibilityEventHandler)
public T sendAccessibilityEventUncheckedHandler(EventHandler<SendAccessibilityEventUncheckedEvent> sendAccessibilityEventUncheckedHandler)
public T shadowElevationAttr(int resId, int defaultResId)
public T shadowElevationAttr(int resId)
public T shadowElevationDip(float shadowElevation)
public T shadowElevationPx(float shadowElevation)
Build.VERSION_CODES
and above.public T shadowElevationRes(int resId)
public T shadowElevation(DynamicValue<Float> value)
DynamicValue
object to the elevation value for this Componentvalue
- controller for the elevation valuepublic T stateListAnimator(StateListAnimator stateListAnimator)
View
into components world. However, since the aforementioned view's method is available only on
API 21 and above, calling this method on lower APIs will have no effect. On the legit
versions, on the other hand, calling this method will lead to the component being wrapped
into a viewpublic T stateListAnimatorRes(int resId)
View
into components world. However, since the aforementioned view's method is available only on
API 21 and above, calling this method on lower APIs will have no effect. On the legit
versions, on the other hand, calling this method will lead to the component being wrapped
into a viewpublic T touchHandler(EventHandler<TouchEvent> touchHandler)
public T transitionKeyType(Transition.TransitionKeyType type)
public T translationX(DynamicValue<Float> value)
DynamicValue
object to the translationX value for this Componentvalue
- controller for the translationY valuepublic T translationY(DynamicValue<Float> value)
DynamicValue
object to the translationY value for this Componentvalue
- controller for the translationY valuepublic T unfocusedHandler(EventHandler<UnfocusedVisibleEvent> unfocusedHandler)
public T useHeightAsBaseline(boolean useHeightAsBaseline)
public T viewTags(<any> viewTags)
public T visibilityChangedHandler(EventHandler<VisibilityChangedEvent> visibilityChangedHandler)
public T visibleHandler(EventHandler<VisibleEvent> visibleHandler)
public T visibleHeightRatio(float visibleHeightRatio)
public T visibleWidthRatio(float visibleWidthRatio)
public T widthAttr(int resId, int defaultResId)
widthPx(int)
public T widthAttr(int resId)
widthPx(int)
public T widthDip(float width)
widthPx(int)
public T widthPercent(float percent)
percent
- a value between 0 and 100.widthPx(int)
public T widthPx(int width)
public T widthRes(int resId)
widthPx(int)
public T wrapInView()
protected void init(ComponentContext c, int defStyleAttr, int defStyleRes, Component component)
protected static void checkArgs(int requiredPropsCount, BitSet required, String[] requiredPropsNames)
requiredPropsCount
- expected number of propsrequired
- the bit set that identifies which props have been suppliedrequiredPropsNames
- the names of all props used for a useful error message