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
Modifier and Type | Field and Description |
---|---|
protected ResourceResolver |
mResourceResolver |
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
T |
accessibilityRole(String role) |
T |
alignSelf(YogaAlign alignSelf)
Controls how a child aligns in the cross direction, overriding the alignItems of the parent.
|
T |
alpha(float alpha)
Sets the alpha (opacity) of this component.
|
T |
aspectRatio(float aspectRatio) |
T |
background(Drawable background) |
T |
background(Reference.Builder<? extends Drawable> builder) |
T |
background(Reference<? extends Drawable> background)
Deprecated.
just use
background(Drawable) instead. |
T |
backgroundAttr(int resId) |
T |
backgroundAttr(int resId,
int defaultResId) |
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 |
clickHandler(EventHandler<ClickEvent> clickHandler) |
T |
clipToOutline(boolean clipToOutline) |
T |
contentDescription(CharSequence contentDescription) |
T |
contentDescription(int stringId) |
T |
contentDescription(int stringId,
Object... formatArgs) |
T |
dispatchPopulateAccessibilityEventHandler(EventHandler<DispatchPopulateAccessibilityEventEvent> dispatchPopulateAccessibilityEventHandler) |
T |
duplicateParentState(boolean duplicateParentState) |
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) |
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 |
heightAttr(int resId) |
T |
heightAttr(int resId,
int defaultResId) |
T |
heightDip(float height) |
T |
heightPercent(float percent) |
T |
heightPx(int height) |
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 |
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) |
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) |
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) |
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.
|
protected void |
release() |
T |
rotation(float rotation)
Sets the degree that this component is rotated around the pivot point.
|
T |
scale(float scale)
Sets the scale (scaleX and scaleY) on this component.
|
T |
selected(boolean isSelected) |
T |
sendAccessibilityEventHandler(EventHandler<SendAccessibilityEventEvent> sendAccessibilityEventHandler) |
T |
sendAccessibilityEventUncheckedHandler(EventHandler<SendAccessibilityEventUncheckedEvent> sendAccessibilityEventUncheckedHandler) |
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
android.view.View#setStateListAnimator(android.animation.StateListAnimator)
into components world. |
T |
stateListAnimatorRes(int resId)
Ports
android.view.View#setStateListAnimator(android.animation.StateListAnimator)
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 |
unfocusedHandler(EventHandler<UnfocusedVisibleEvent> unfocusedHandler) |
T |
viewTag(Object viewTag) |
T |
viewTags(<any> viewTags) |
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) |
T |
widthPx(int width) |
T |
widthRes(int resId) |
T |
wrapInView() |
protected ResourceResolver mResourceResolver
protected void init(ComponentContext c, @AttrRes int defStyleAttr, @StyleRes int defStyleRes, Component component)
@Nullable 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 abstract T getThis()
protected void release()
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 messagepublic abstract Component build()
public T layoutDirection(@Nullable 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 alignSelf(@Nullable YogaAlign alignSelf)
Default: YogaAlign.AUTO
public T positionType(@Nullable YogaPositionType positionType)
Default: YogaPositionType.RELATIVE
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 flexGrow(float flexGrow)
Default: 0
public T flexShrink(float flexShrink)
Default: 1
public T flexBasisPx(@Px int flexBasis)
Default: 0
public T flexBasisPercent(float percent)
percent
- a value between 0 and 100.flexBasisPx(int)
public T flexBasisAttr(@AttrRes int resId, @DimenRes int defaultResId)
flexBasisPx(int)
public T flexBasisAttr(@AttrRes int resId)
flexBasisPx(int)
public T flexBasisRes(@DimenRes int resId)
flexBasisPx(int)
public T flexBasisDip(@Dimension(unit=0) float flexBasis)
flexBasisPx(int)
public T importantForAccessibility(int importantForAccessibility)
public T duplicateParentState(boolean duplicateParentState)
public T marginPercent(@Nullable YogaEdge edge, float percent)
percent
- a value between 0 and 100.public T marginAttr(@Nullable YogaEdge edge, @AttrRes int resId, @DimenRes int defaultResId)
public T marginDip(@Nullable YogaEdge edge, @Dimension(unit=0) float margin)
public T paddingPercent(@Nullable YogaEdge edge, float percent)
percent
- a value between 0 and 100.public T paddingAttr(@Nullable YogaEdge edge, @AttrRes int resId, @DimenRes int defaultResId)
public T paddingDip(@Nullable YogaEdge edge, @Dimension(unit=0) float padding)
public T positionPx(@Nullable YogaEdge edge, @Px 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 positionPercent(@Nullable YogaEdge edge, float percent)
percent
- a value between 0 and 100.positionPx(com.facebook.yoga.YogaEdge, int)
public T positionAttr(@Nullable YogaEdge edge, @AttrRes int resId, @DimenRes int defaultResId)
public T positionDip(@Nullable YogaEdge edge, @Dimension(unit=0) float position)
public T widthPercent(float percent)
percent
- a value between 0 and 100.public T widthDip(@Dimension(unit=0) float width)
public T minWidthPercent(float percent)
percent
- a value between 0 and 100.public T minWidthDip(@Dimension(unit=0) float minWidth)
public T maxWidthPercent(float percent)
percent
- a value between 0 and 100.public T maxWidthDip(@Dimension(unit=0) float maxWidth)
public T heightPercent(float percent)
percent
- a value between 0 and 100.public T heightDip(@Dimension(unit=0) float height)
public T minHeightPercent(float percent)
percent
- a value between 0 and 100.public T minHeightDip(@Dimension(unit=0) float minHeight)
public T maxHeightPercent(float percent)
percent
- a value between 0 and 100.public T maxHeightDip(@Dimension(unit=0) float maxHeight)
public T aspectRatio(float aspectRatio)
public T touchExpansionAttr(@Nullable YogaEdge edge, @AttrRes int resId, @DimenRes int defaultResId)
public T touchExpansionDip(@Nullable YogaEdge edge, @Dimension(unit=0) float touchExpansion)
@Deprecated public T background(@Nullable Reference<? extends Drawable> background)
background(Drawable)
instead.public T background(@Nullable Reference.Builder<? extends Drawable> builder)
public T background(@Nullable Drawable background)
public T backgroundAttr(@AttrRes int resId, @DrawableRes int defaultResId)
public T backgroundRes(@DrawableRes int resId)
public T backgroundColor(int backgroundColor)
public T foreground(@Nullable Drawable foreground)
public T foregroundAttr(@AttrRes int resId, @DrawableRes int defaultResId)
public T foregroundRes(@DrawableRes int resId)
public T foregroundColor(int foregroundColor)
public T wrapInView()
public T clickHandler(@Nullable EventHandler<ClickEvent> clickHandler)
public T longClickHandler(@Nullable EventHandler<LongClickEvent> longClickHandler)
public T focusChangeHandler(@Nullable EventHandler<FocusChangedEvent> focusChangeHandler)
public T touchHandler(@Nullable EventHandler<TouchEvent> touchHandler)
public T interceptTouchHandler(@Nullable EventHandler<InterceptTouchEvent> interceptTouchHandler)
public T focusable(boolean isFocusable)
public T enabled(boolean isEnabled)
public T selected(boolean isSelected)
public T visibleHeightRatio(float visibleHeightRatio)
public T visibleWidthRatio(float visibleWidthRatio)
public T visibleHandler(@Nullable EventHandler<VisibleEvent> visibleHandler)
public T focusedHandler(@Nullable EventHandler<FocusedVisibleEvent> focusedHandler)
public T unfocusedHandler(@Nullable EventHandler<UnfocusedVisibleEvent> unfocusedHandler)
public T fullImpressionHandler(@Nullable EventHandler<FullImpressionVisibleEvent> fullImpressionHandler)
public T invisibleHandler(@Nullable EventHandler<InvisibleEvent> invisibleHandler)
public T contentDescription(@Nullable CharSequence contentDescription)
public T contentDescription(@StringRes int stringId)
public T contentDescription(@StringRes int stringId, Object... formatArgs)
public T viewTags(@Nullable <any> viewTags)
public T shadowElevationPx(float shadowElevation)
Build.VERSION_CODES
and above.public T shadowElevationDip(@Dimension(unit=0) float shadowElevation)
public T outlineProvider(@Nullable ViewOutlineProvider outlineProvider)
public T clipToOutline(boolean clipToOutline)
public T dispatchPopulateAccessibilityEventHandler(@Nullable EventHandler<DispatchPopulateAccessibilityEventEvent> dispatchPopulateAccessibilityEventHandler)
public T onInitializeAccessibilityEventHandler(@Nullable EventHandler<OnInitializeAccessibilityEventEvent> onInitializeAccessibilityEventHandler)
public T onInitializeAccessibilityNodeInfoHandler(@Nullable EventHandler<OnInitializeAccessibilityNodeInfoEvent> onInitializeAccessibilityNodeInfoHandler)
public T onPopulateAccessibilityEventHandler(@Nullable EventHandler<OnPopulateAccessibilityEventEvent> onPopulateAccessibilityEventHandler)
public T onRequestSendAccessibilityEventHandler(@Nullable EventHandler<OnRequestSendAccessibilityEventEvent> onRequestSendAccessibilityEventHandler)
public T performAccessibilityActionHandler(@Nullable EventHandler<PerformAccessibilityActionEvent> performAccessibilityActionHandler)
public T sendAccessibilityEventHandler(@Nullable EventHandler<SendAccessibilityEventEvent> sendAccessibilityEventHandler)
public T sendAccessibilityEventUncheckedHandler(@Nullable EventHandler<SendAccessibilityEventUncheckedEvent> sendAccessibilityEventUncheckedHandler)
public T alpha(float alpha)
public T scale(float scale)
public T rotation(float rotation)
public T stateListAnimator(@Nullable StateListAnimator stateListAnimator)
android.view.View#setStateListAnimator(android.animation.StateListAnimator)
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(@DrawableRes int resId)
android.view.View#setStateListAnimator(android.animation.StateListAnimator)
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 view