【问题标题】:Transparent part of png Image showing white colourpng 图像的透明部分显示白色
【发布时间】:2018-07-18 15:57:50
【问题描述】:

我在 Image 标签中有一个 png 图像。部分图像具有透明背景。在我的安卓手机中,它显示为白色。我希望去除白色部分并使其透明。

这是我的代码 -

export default class LoginScreen extends Component {
  render() {
    return (
      <View style={styles.container}>
        <View style = {styles.topContainer}>
        <Image style = {styles.logoContainer}
        source = {require('../images/black_header.png')} />
      </View>
     </View>
    );
  }
}


const styles = StyleSheet.create({
  logoContainer: {
    resizeMode: 'contain',
    backgroundColor: "rgba(0,0,0,0)",
    width: null,
    height: 254,
  },
  container: {
    backgroundColor: "#f7f7f7"
  },
  topContainer: {
    backgroundColor: "rgba(0,0,0,0)"
  }
});

【问题讨论】:

  • 提及为什么投反对票
  • 它必须通过透明图像显示一些背景颜色。当前是否显示容器样式中定义的浅灰色?
  • @RobWalker 没有。它显示白色。

标签: javascript react-native


【解决方案1】:

我不知道您是否遇到与我相同的问题,但我遇到了一些类似的问题并将StyleSheet.absoluteFillObject 添加到logoContainer 解决了它。

【讨论】:

    【解决方案2】:

    写在图片style={{ position:'absolute'}}

    【讨论】:

      猜你喜欢
      • 2013-07-26
      • 2018-07-26
      • 2011-06-09
      • 2020-11-29
      • 2015-09-05
      • 1970-01-01
      • 2020-03-03
      • 2018-10-31
      • 1970-01-01
      相关资源
      最近更新 更多