Center align image in a span
Reviewed By: achen1 Differential Revision: D7750114 fbshipit-source-id: 84b4eaa2da01ac9c49a569d37f7a32eab1e5aca8
This commit is contained in:
parent
de08f4ab6c
commit
2e7dbc82b3
|
@ -160,8 +160,10 @@ public class FrescoBasedReactTextInlineImageSpan extends TextInlineImageSpan {
|
|||
|
||||
canvas.save();
|
||||
|
||||
// Align to baseline by default
|
||||
int transY = y - mDrawable.getBounds().bottom;
|
||||
// Align to center
|
||||
int fontHeight = (int)(paint.descent() - paint.ascent());
|
||||
int centerY = y + (int)paint.descent() - fontHeight / 2;
|
||||
int transY = centerY - (mDrawable.getBounds().bottom - mDrawable.getBounds().top) / 2;
|
||||
|
||||
canvas.translate(x, transY);
|
||||
mDrawable.draw(canvas);
|
||||
|
|
Loading…
Reference in New Issue