From 03619daf0456d1de4fdcb71b0a7f2c6b42ef7ba9 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Mon, 21 Mar 2016 06:26:19 -0700 Subject: [PATCH] Align inline images to baseline by default on Android Summary:Full discussion in FB group: https://www.facebook.com/groups/reactnativeoss/permalink/1532669803696315/ **Test plan** In the following examples I use a different image than the one built in to UIExplorer because this one better demonstrates the alignment: ![before](https://cloud.githubusercontent.com/assets/90494/13887933/c183e60e-ecfb-11e5-98cb-9c6d0104bb23.png) ![after](https://cloud.githubusercontent.com/assets/90494/13887937/c896eb76-ecfb-11e5-88fa-979a1ba62714.png) ![ios](https://cloud.githubusercontent.com/assets/90494/13888029/40b1f3ee-ecfc-11e5-9d71-1cfdf8213ec8.png) If you want to try this for yourself, you can copy this into the inline image example: ```javascript This text contains an inline image, look at it! . Neat, huh? ``` Closes https://github.com/facebook/react-native/pull/6528 Differential Revision: D3075801 Pulled By: foghina fb-gh-sync-id: afbe5873d865cd1fa90f7713563539ad22633879 shipit-source-id: afbe5873d865cd1fa90f7713563539ad22633879 --- .../frescosupport/FrescoBasedReactTextInlineImageSpan.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java index d62ecf0ce4c455..0613457e59f7b2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageSpan.java @@ -148,6 +148,9 @@ public void draw( int transY = bottom - mDrawable.getBounds().bottom; + // Align to baseline by default + transY -= paint.getFontMetricsInt().descent; + canvas.translate(x, transY); mDrawable.draw(canvas); canvas.restore();