public final class Text extends Component
Example Text usage:
final SpannableStringBuilder spannable = new SpannableStringBuilder();
spannable.setSpan(new StyleSpan(Typeface.BOLD), start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
Text.create(c)
.text(spannable) // String can be used
.textSizeDip(20)
.maxLines(3)
.ellipsize(TextUtils.TruncateAt.END)
.textColor(Color.BLACK)
.build()
com.facebook.litho.widget.TextSpec| Modifier and Type | Class and Description |
|---|---|
static class |
Text.Builder |
Component.ContainerBuilder<T extends Component.ContainerBuilder<T>>ComponentLifecycle.MountType, ComponentLifecycle.RenderData, ComponentLifecycle.TransitionContainer| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canMeasure()
Whether this
ComponentLifecycle is able to measure itself according to specific size
constraints. |
protected boolean |
canPreallocate() |
protected void |
copyInterStageImpl(Component component) |
static Text.Builder |
create(ComponentContext context) |
static Text.Builder |
create(ComponentContext context,
int defStyleAttr,
int defStyleRes) |
protected int |
getExtraAccessibilityNodeAt(int x,
int y)
Get extra accessibility node id at a given point within the component.
|
protected int |
getExtraAccessibilityNodesCount()
The number of extra accessibility nodes that this component wishes to provides to the
accessibility system.
|
ComponentLifecycle.MountType |
getMountType()
This indicates the type of the
Object that will be returned by ComponentLifecycle.mount(com.facebook.litho.ComponentContext, java.lang.Object). |
static EventHandler |
getTextOffsetOnTouchEventHandler(ComponentContext context) |
boolean |
implementsAccessibility()
Whether this component will populate any accessibility nodes or events that are passed to it.
|
boolean |
implementsExtraAccessibilityNodes()
Whether this component will expose any virtual views to the accessibility framework
|
boolean |
isEquivalentTo(Component other)
Compares this component to a different one to check if they are the same
|
protected boolean |
isMountSizeDependent() |
boolean |
isPureRender() |
Text |
makeShallowCopy() |
protected void |
onBoundsDefined(ComponentContext c,
ComponentLayout layout)
Called after the layout calculation is finished and the given
ComponentLayout has its
bounds defined. |
protected Object |
onCreateMountContent(Context c)
Create the object that will be mounted in the
LithoView. |
protected void |
onLoadStyle(ComponentContext c) |
protected void |
onMeasure(ComponentContext context,
ComponentLayout layout,
int widthSpec,
int heightSpec,
Size size) |
protected void |
onMount(ComponentContext c,
Object textDrawable)
Deploy all UI elements representing the final bounds defined in the given
ComponentLayout. |
protected void |
onPopulateAccessibilityNode(View host,
AccessibilityNodeInfoCompat node)
Populate an accessibility node with information about the component.
|
protected void |
onPopulateExtraAccessibilityNode(AccessibilityNodeInfoCompat node,
int extraNodeIndex,
int componentBoundsLeft,
int componentBoundsTop)
Populate an extra accessibility node.
|
protected void |
onUnmount(ComponentContext c,
Object textDrawable)
Unload UI elements associated with this component.
|
protected int |
poolSize() |
bindDynamicProp, canResolve, clearCachedLayout, getCommonProps, getDynamicProps, getEventDispatcher, getHandle, getId, getKey, getScopedContext, getSimpleName, getSimpleNameDelegate, getStateContainer, hasBackgroundSet, hasClickHandlerSet, measure, measureMightNotCacheInternalNode, recordEventTrigger, registerWorkingRange, retrieveValue, setScopedContext, updateInternalChildState, willRenderacceptTriggerEvent, applyPreviousRenderData, callsShouldUpdateOnMount, createInitialState, createMountContent, dispatchErrorEvent, dispatchErrorEvent, dispatchOnEnteredRange, dispatchOnEvent, dispatchOnExitedRange, getEventTrigger, getEventTrigger, getTreePropsForChildren, hasAttachDetachCallback, hasChildLithoViews, hasState, isLayoutSpecWithSizeSpecCheck, needsPreviousRenderData, newEventHandler, newEventTrigger, onAttached, onBind, onCreateLayout, onCreateLayoutWithSizeSpec, onCreateMountContentPool, onCreateTransition, onDetached, onError, onMeasureBaseline, onPrepare, onShouldCreateLayoutWithNewSizeSpec, onUnbind, populateTreeProps, recordRenderData, resolve, shouldAlwaysRemeasure, shouldUpdate, shouldUseGlobalPool, transferStatepublic boolean isEquivalentTo(Component other)
ComponentThis is used to be able to skip rendering a component again. We avoid using the Object.equals(Object) so we can optimize the code better over time since we don't have to
adhere to the contract required for a equals method.
isEquivalentTo in interface Equivalence<Component>isEquivalentTo in class Componentother - the component to compare toprotected void copyInterStageImpl(Component component)
copyInterStageImpl in class Componentpublic Text makeShallowCopy()
makeShallowCopy in class Componentprotected void onLoadStyle(ComponentContext c)
onLoadStyle in class ComponentLifecycleprotected void onMeasure(ComponentContext context, ComponentLayout layout, int widthSpec, int heightSpec, Size size)
onMeasure in class ComponentLifecycleprotected boolean canMeasure()
ComponentLifecycleComponentLifecycle is able to measure itself according to specific size
constraints.canMeasure in class ComponentLifecycleprotected void onBoundsDefined(ComponentContext c, ComponentLayout layout)
ComponentLifecycleComponentLayout has its
bounds defined. You can use ComponentLayout.getX(), ComponentLayout.getY(),
ComponentLayout.getWidth(), and ComponentLayout.getHeight() to get the size and
position of the component in the layout tree.onBoundsDefined in class ComponentLifecyclec - The Context used by this component.layout - The ComponentLayout with defined position and size.protected Object onCreateMountContent(Context c)
ComponentLifecycleLithoView.onCreateMountContent in class ComponentLifecyclec - The Context to be used to create the content.protected void onMount(ComponentContext c, Object textDrawable)
ComponentLifecycleComponentLayout. Return either a Drawable or a View or null to be
mounted.onMount in class ComponentLifecyclec - The ComponentContext to mount the component into.protected void onUnmount(ComponentContext c, Object textDrawable)
ComponentLifecycleonUnmount in class ComponentLifecyclec - The Context for this mount operation.textDrawable - The Drawable or View mounted by this component.protected void onPopulateAccessibilityNode(View host,
AccessibilityNodeInfoCompat node)
ComponentLifecycleonPopulateAccessibilityNode in class ComponentLifecyclenode - node to populatepublic boolean implementsAccessibility()
ComponentLifecycleimplementsAccessibility in class ComponentLifecycleprotected int getExtraAccessibilityNodesCount()
ComponentLifecyclegetExtraAccessibilityNodesCount in class ComponentLifecycleprotected void onPopulateExtraAccessibilityNode(AccessibilityNodeInfoCompat node,
int extraNodeIndex,
int componentBoundsLeft,
int componentBoundsTop)
ComponentLifecycleonPopulateExtraAccessibilityNode in class ComponentLifecyclenode - node to populateextraNodeIndex - index of extra nodecomponentBoundsLeft - left bound of the mounted componentcomponentBoundsTop - top bound of the mounted componentpublic boolean implementsExtraAccessibilityNodes()
ComponentLifecycleimplementsExtraAccessibilityNodes in class ComponentLifecycleprotected int getExtraAccessibilityNodeAt(int x,
int y)
ComponentLifecyclegetExtraAccessibilityNodeAt in class ComponentLifecyclex - x co-ordinate within the mounted componenty - y co-ordinate within the mounted componentExploreByTouchHelper#INVALID_IDpublic ComponentLifecycle.MountType getMountType()
ComponentLifecycleObject that will be returned by ComponentLifecycle.mount(com.facebook.litho.ComponentContext, java.lang.Object).getMountType in class ComponentLifecycleComponentLifecycle.MountTypeprotected int poolSize()
poolSize in class ComponentLifecycleprotected boolean canPreallocate()
canPreallocate in class ComponentLifecycleprotected boolean isMountSizeDependent()
isMountSizeDependent in class ComponentLifecyclepublic boolean isPureRender()
isPureRender in class ComponentLifecyclepublic static EventHandler getTextOffsetOnTouchEventHandler(ComponentContext context)
public static Text.Builder create(ComponentContext context)
public static Text.Builder create(ComponentContext context, int defStyleAttr, int defStyleRes)