2016-03-04 71 views

回答

1

您可以通過以下方式完成此操作:它會爲您提供ScrollView的高度。

onContentSizeChange = (width, height) => { 
    console.log('scrollview width : ' + width); 
    console.log('scrollview height : ' + height); 
}; 

render() { 
    return (
    <ScrollView style={{height: Dimensions.get('window').height, backgroundColor: '#DDDDDD'}} onContentSizeChange={this.onContentSizeChange}> 
     {_.map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], (number) => { 
     return <Text key={number} style={{textAlign: 'center', paddingTop: 30, paddingBottom: 30, backgroundColor: number % 2 ? 'red' : 'blue'}}>{number}</Text>; 
     })} 
    </ScrollView> 
); 
}; 

我已經設置了一個工作示例here

+0

它正在爲我工​​作。謝謝 :) –

相關問題