1
我試圖添加一個圖像(由圖像全尺寸)到一個ScrollView
組件,它的想法是讓圖像在它自己的大小(不限制它),但而是讓水平和垂直滾動(取決於圖像)。 所以我使用Image.getSize()
爲它ScrollView
內,這裏是我的組件,ScrollView內部的大圖不會讓滾動
import React, { Component } from 'react';
import { Image, ScrollView } from 'react-native';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
width: 10,
height: 10,
image: 'http://www.francedimanche.fr/parole/wp-content/uploads/2017/08/Angelina-Jolie.png',
}
}
componentDidMount() {
Image.getSize(this.state.image, (width, height) => {
this.setState({ width, height });
});
}
render() {
return (
<ScrollView>
<Image
style={{ width: this.state.width, height: this.state.height }}
source={{uri: this.state.image}}
/>
</ScrollView>
);
}
}
的感謝!