Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Align inline images to baseline by default on Android
Browse files Browse the repository at this point in the history
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
<Text style={{fontSize: 20}}>
  This text contains an inline image, look at it! <Image source={{uri: 'https://d3fzfeknznuaac.cloudfront.net/images4/[email protected]'}} style={{height: 15, width: 15}} />. Neat, huh?
</Text>
```
Closes facebook#6528

Differential Revision: D3075801

Pulled By: foghina

fb-gh-sync-id: afbe5873d865cd1fa90f7713563539ad22633879
shipit-source-id: afbe5873d865cd1fa90f7713563539ad22633879
  • Loading branch information
brentvatne authored and Facebook Github Bot 2 committed Mar 21, 2016
1 parent 322f210 commit 03619da
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 03619da

Please sign in to comment.