From 3b6d029a55efe1ffa5afcafe60d2d2445aadd502 Mon Sep 17 00:00:00 2001 From: Andrei Coman Date: Tue, 29 Sep 2015 09:12:19 -0700 Subject: [PATCH] Fix background color issue Differential Revision: D2489578 committer: Service User --- Examples/UIExplorer/TextExample.android.js | 9 +++++++++ Examples/UIExplorer/TextInputExample.android.js | 7 +++++++ .../facebook/react/views/text/ReactTextShadowNode.java | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Examples/UIExplorer/TextExample.android.js b/Examples/UIExplorer/TextExample.android.js index 4159d0c18..42d17ed07 100644 --- a/Examples/UIExplorer/TextExample.android.js +++ b/Examples/UIExplorer/TextExample.android.js @@ -310,6 +310,15 @@ var TextExample = React.createClass({ + + Same alpha as background, + + Inherited alpha from background, + + Reapply alpha + + + diff --git a/Examples/UIExplorer/TextInputExample.android.js b/Examples/UIExplorer/TextInputExample.android.js index 9659e9180..99f28231f 100644 --- a/Examples/UIExplorer/TextInputExample.android.js +++ b/Examples/UIExplorer/TextInputExample.android.js @@ -221,6 +221,13 @@ exports.examples = [ style={styles.singleLine} underlineColorAndroid="blue" /> + + + Darker backgroundColor + + ); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java index 8fb0ee4d6..21540b59c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java @@ -134,7 +134,7 @@ public class ReactTextShadowNode extends ReactShadowNode { // a new spannable will be wiped out List ops = new ArrayList(); buildSpannedFromTextCSSNode(textCSSNode, sb, ops); - if (textCSSNode.mFontSize == -1) { + if (textCSSNode.mFontSize == UNSET) { sb.setSpan( new AbsoluteSizeSpan((int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP))), 0, @@ -315,7 +315,8 @@ public class ReactTextShadowNode extends ReactShadowNode { } markUpdated(); } - if (styles.hasKey(ViewProps.BACKGROUND_COLOR)) { + // Don't apply background color to anchor TextView since it will be applied on the View directly + if (styles.hasKey(ViewProps.BACKGROUND_COLOR) && this.isVirtualAnchor() == false) { if (styles.isNull(ViewProps.BACKGROUND_COLOR)) { mIsBackgroundColorSet = false; } else {