-
public final class SpanBackgroundHelperHelper class to draw multi-line rounded background to certain parts of a text. The start/end positions of the backgrounds are annotated with android.text.Annotation class. Each annotation should have the annotation key set to rounded.
i.e.:
<!--without the quotes at the begining and end Android strips the whitespace and also starts the annotation at the wrong position--> <string name="ltr">"this is <annotation key="rounded">a regular</annotation> paragraph."</string>Note: BiDi text is not supported.
-
-
Field Summary
Fields Modifier and Type Field Description private final IntegerhorizontalPaddingprivate final IntegerverticalPadding
-
Method Summary
Modifier and Type Method Description final IntegergetHorizontalPadding()final IntegergetVerticalPadding()final Unitdraw(Canvas canvas, Spanned text, Layout layout)Call this function during onDraw of another widget such as TextView. final UnitclearCachedPositions()-
-
Constructor Detail
-
SpanBackgroundHelper
SpanBackgroundHelper(Class<?> spanType, Integer horizontalPadding, Integer verticalPadding, Drawable drawable, Drawable drawableLeft, Drawable drawableMid, Drawable drawableRight)
- Parameters:
horizontalPadding- the padding to be applied to left & right of the backgroundverticalPadding- the padding to be applied to top & bottom of the backgrounddrawable- the drawable used to draw the backgrounddrawableLeft- the drawable used to draw left edge of the backgrounddrawableMid- the drawable used to draw for whole linedrawableRight- the drawable used to draw right edge of the background
-
-
Method Detail
-
getHorizontalPadding
final Integer getHorizontalPadding()
-
getVerticalPadding
final Integer getVerticalPadding()
-
draw
final Unit draw(Canvas canvas, Spanned text, Layout layout)
Call this function during onDraw of another widget such as TextView.
- Parameters:
canvas- Canvas to draw ontolayout- Layout that contains the text
-
clearCachedPositions
final Unit clearCachedPositions()
-
-
-
-