Skip to content

Instantly share code, notes, and snippets.

Created February 19, 2015 11:55
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Image Centered Span
class ImageCenteredSpan extends ImageSpan {
public ImageCenteredSpan(Drawable d) {
public void draw(Canvas canvas, CharSequence text,
int start, int end, float x,
int top, int y, int bottom, Paint paint) {
Drawable b = getDrawable();;
int transY = bottom - b.getBounds().bottom;
transY -= paint.getFontMetricsInt().descent / 2;
canvas.translate(x, transY);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment