我想調整listView行的相對於其內容的圖像和文本的大小, 圖像是遠程的,我正在從firebase中讀取它,並且正在顯示它與uri, 當我把一個寬度或高度的行,圖像顯示,但我想要做的是調整行的大小,以便它需要圖像的高度。listView關於其內容的行大小
我發現這個解決方案
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
View,
Image
} = React;
var TestCmp = React.createClass({
render: function() {
return (
<View style={styles.imageContainer}>
<Image style={styles.image} source={{uri: 'http://lorempixel.com/200/400/sports/5/![enter image description here][2]'}} />
</View>
);
}
});
var styles = StyleSheet.create({
imageContainer: {
flex: 1,
alignItems: 'stretch'
},
image: {
flex: 1
}
});
AppRegistry.registerComponent('RCTTest',() => TestCmp);
但它不使用ListView行工作
我也想給這ListView的行中的容器: 柔性:1, alignItems:「拉伸」, 左:0, 右:0, 高度:500,
和圖像: 撓曲:1,
但是當然圖像的高度爲500,並且它會被拉伸,因此它的某些部分將不可見。
你會很高興提供一個小的RNPlay(https://rnplay.org/)片段顯示問題?這樣,其他人可以更容易地嘗試爲你解決問題;) –