| java.lang.Object | ||||
| ↳ | android.text.style.CharacterStyle | |||
| ↳ | android.text.style.MetricAffectingSpan | |||
| ↳ | android.text.style.ReplacementSpan | |||
| ↳ | com.facebook.widget.text.span.BetterImageSpan | |||
Known Direct Subclasses
|
A better implementation of image spans that also supports centering images against the text.
In order to migrate from ImageSpan, replace new ImageSpan(drawable, alignment) with
new BetterImageSpan(drawable, BetterImageSpan.normalizeAlignment(alignment)).
There are 2 main differences between BetterImageSpan and ImageSpan: 1. Pass in ALIGN_CENTER to center images against the text. 2. ALIGN_BOTTOM no longer unnecessarily increases the size of the text: DynamicDrawableSpan (ImageSpan's parent) adjusts sizes as if alignment was ALIGN_BASELINE which can lead to unnecessary whitespace.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| @interface | BetterImageSpan.BetterImageSpanAlignment | ||||||||||
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | ALIGN_BASELINE | ||||||||||
| int | ALIGN_BOTTOM | ||||||||||
| int | ALIGN_CENTER | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| BetterImageSpan(Drawable drawable) | |||||||||||
| BetterImageSpan(Drawable drawable, int verticalAlignment) | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void | draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) | ||||||||||
| Drawable | getDrawable() | ||||||||||
| int |
getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fontMetrics)
Returns the width of the image span and increases the height if font metrics are available.
| ||||||||||
| final static int |
normalizeAlignment(int alignment)
A helper function to allow dropping in BetterImageSpan as a replacement to ImageSpan, and
allowing for center alignment if passed in.
| ||||||||||
| void | updateBounds() | ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.text.style.ReplacementSpan
| |||||||||||
From class
android.text.style.MetricAffectingSpan
| |||||||||||
From class
android.text.style.CharacterStyle
| |||||||||||
From class
java.lang.Object
| |||||||||||
Returns the width of the image span and increases the height if font metrics are available.
A helper function to allow dropping in BetterImageSpan as a replacement to ImageSpan, and allowing for center alignment if passed in.