java.lang.Object |
↳ |
android.text.style.CharacterStyle |
|
↳ |
android.text.style.MetricAffectingSpan |
|
|
↳ |
android.text.style.ReplacementSpan |
|
|
|
↳ |
com.facebook.widget.text.span.BetterImageSpan |
Known Direct Subclasses
|
Class Overview
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.
Summary
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
abstract
void
|
draw(Canvas arg0, CharSequence arg1, int arg2, int arg3, float arg4, int arg5, int arg6, int arg7, Paint arg8)
|
abstract
int
|
getSize(Paint arg0, CharSequence arg1, int arg2, int arg3, Paint.FontMetricsInt arg4)
|
void
|
updateDrawState(TextPaint arg0)
|
void
|
updateMeasureState(TextPaint arg0)
|
|
From class
android.text.style.MetricAffectingSpan
CharacterStyle
|
getUnderlying()
|
abstract
void
|
updateMeasureState(TextPaint arg0)
|
|
From class
android.text.style.CharacterStyle
CharacterStyle
|
getUnderlying()
|
abstract
void
|
updateDrawState(TextPaint arg0)
|
static
CharacterStyle
|
wrap(CharacterStyle arg0)
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Constants
public
static
final
int
ALIGN_BASELINE
Constant Value:
1
(0x00000001)
public
static
final
int
ALIGN_BOTTOM
Constant Value:
0
(0x00000000)
public
static
final
int
ALIGN_CENTER
Constant Value:
2
(0x00000002)
Public Constructors
public
BetterImageSpan
(Drawable drawable)
public
BetterImageSpan
(Drawable drawable, int verticalAlignment)
Public Methods
public
void
draw
(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
public
Drawable
getDrawable
()
public
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.
public
static
final
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.
public
void
updateBounds
()