【问题标题】:Full Screen Background Image behaves differently from network and local storage全屏背景图像的行为不同于网络和本地存储
【发布时间】:2016-11-20 15:57:09
【问题描述】:

我正在尝试将背景图像拉伸到全屏。
从网络和本地存储中获取图像时,图像的行为似乎有所不同。

此函数不会按要求拉伸图像(距右侧约 70 像素的白边距): 这是我的 render() 基金:

  var BackgroundImage = require('./images/logo_og.png');

  render(){
    return(
      <View style={[{flex: 1, alignItems: 'stretch'}]}>
      <Image source={BackgroundImage} style={[{flex: 1}]} >
      </Image>
    </View>
  );

相同的渲染函数可以很好地显示从网络获取的图像:

  render(){
    return(
      <View style={[{flex: 1, alignItems: 'stretch'}]}>
      <Image source={{uri:'https://facebook.github.io/react/img/logo_og.png'}} style={[{flex: 1}]} >
      </Image>
    </View>
  );

知道发生了什么吗?

【问题讨论】:

    标签: react-native react-native-android


    【解决方案1】:

    here 报告了类似问题。尝试将图像的宽度设置为null:

    <Image source={BackgroundImage} style={[{flex: 1, width: null}]} >
    

    【讨论】:

      猜你喜欢
      • 2016-12-31
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 2012-03-09
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多