2017-03-31 109 views
0

我有一个资产,在我们的应用程序中使用透明背景。在iOS上,如果在Android上为Image组件设置backgroundColor: 'transparent',则它会始终呈现浅灰色背景。在Android上使用React Native的图像的透明backgroundColor

事实上,backgroundColor值似乎在Android上完全被忽略。

这是它的外观现在:

enter image description here

<View style={styles.cardHeader}> 
    <Image 
    source={require('../assets/images/greeting.png')} 
    style={styles.greetingImage} /> 
</View> 

样式

cardHeader: { 
    alignSelf: 'stretch', 
    backgroundColor: Color.GREY, 
    paddingTop: 30, 
    borderTopLeftRadius: 5, 
    borderTopRightRadius: 5 
}, 

greetingImage: { 
    alignSelf: 'center', 
    backgroundColor: 'transparent' 
} 
+0

您是否尝试过使用RGBA,而不是“透明”? –

+0

是的@TaylorKing!不幸的是,没有运气。属性backgroundColor似乎在Android上被忽略。 –

+0

嗯,它可能有助于知道你想要达到什么... cardHeader的风格也是如此? –

回答

0

我意识到,我是从shoutem-ui代替react-native进口我Image组件。这就是为什么我不能设置背景颜色,这似乎被前者忽略,而不是后者。

如果你绊倒类似的东西,确保你从右侧包导入COMPONENTES:

import {Image} from 'react-native';