簡體   English   中英

React-Native全屏背景圖片

[英]React-Native FullScreen Backaground Image

因此,L一直在試圖約4天,但我只是似乎無法得到的圖像表現得像它應該在flexbox ,尤其是與cover resizeMode。

我的代碼是:

var Creator = React.createClass({
  render: function() {
  return (
    <View style={ styles.container }>
      <Image source={ require('image!createBg') } style={ styles.image }></Image>
    </View>
  );
 }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  image: {
    flex: 1,
    resizeMode: 'cover'
  }
});

並輸出以下內容(圖像被大規模拉伸,而不是100%的寬度):

flexbox不起作用

任何幫助將不勝感激,只是看不出為什么它不起作用!

resizeMode是Image組件的一個單獨道具,在style道具內部沒有任何作用。 它還需要Image組件的枚舉。 因此,您應該像這樣使用它:

<Image
 source={require('image!createBg')}
 style={styles.image}
 resizeMode={Image.resizeMode.contain} />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM