Skip to content

Instantly share code, notes, and snippets.

View HemangiVekaria's full-sized avatar

Hemangi HemangiVekaria

View GitHub Profile
@lzanita09
lzanita09 / ResizeImageSpan.java
Created June 19, 2014 19:11
ImageSpan subclass that can resize the image to fit the cantainer's width if possible, and recalculate the Rect to avoid overlay text.
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.style.ImageSpan;
import java.lang.ref.WeakReference;
/**
* Subclass of ImageSpan that resizes images automatically to fit the container's width, and then
* re-calculate the size of the image to let TextView know how much space it needs to display