Fix background color issue

Differential Revision: D2489578

committer: Service User <svcscm@fb.com>
This commit is contained in:
Andrei Coman 2015-09-29 09:12:19 -07:00 committed by facebook-github-bot-4
parent 3a664a0008
commit 3b6d029a55
3 changed files with 19 additions and 2 deletions

View File

@ -310,6 +310,15 @@ var TextExample = React.createClass({
</Text>
</Text>
</Text>
<Text style={{backgroundColor: 'rgba(100, 100, 100, 0.3)'}}>
Same alpha as background,
<Text>
Inherited alpha from background,
<Text style={{backgroundColor: 'rgba(100, 100, 100, 0.3)'}}>
Reapply alpha
</Text>
</Text>
</Text>
</UIExplorerBlock>
<UIExplorerBlock title="containerBackgroundColor attribute">
<View style={{flexDirection: 'row', height: 85}}>

View File

@ -221,6 +221,13 @@ exports.examples = [
style={styles.singleLine}
underlineColorAndroid="blue"
/>
<TextInput
defaultValue="Same BackgroundColor as View "
style={[styles.singleLine, {backgroundColor: 'rgba(100, 100, 100, 0.3)'}]}>
<Text style={{backgroundColor: 'rgba(100, 100, 100, 0.3)'}}>
Darker backgroundColor
</Text>
</TextInput>
</View>
);
}

View File

@ -134,7 +134,7 @@ public class ReactTextShadowNode extends ReactShadowNode {
// a new spannable will be wiped out
List<SetSpanOperation> ops = new ArrayList<SetSpanOperation>();
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 {