用 Html.fromHtml() 插入圖片,圖片高度大於文字行高,導致 TextView 只顯示兩行,滾動時高度計算錯誤。
ImageGetter 中根據文字大小縮放 Bitmap
Drawable d = new BitmapDrawable(resources, scaledBitmap);
d.setBounds(0, 0, textLineHeight, textLineHeight);
ReplacementSpan 重寫 getSize() 返回固定高度,draw() 居中繪製圖片RichText、SpanTextView 內部已處理行高對齊確保 ImageSpan 佔用的高度與 TextView 的 lineSpacingExtra、textSize 一致,避免 Layout 重複測量導致跳動。