0
如何在Android的React Native中查找ScrollView底部位置值。我的要求是在加載頁面時,滾動位置必須顯示在頁面的底部。如何在React Native中找到ScrollView for Android的底部位置
如何在Android的React Native中查找ScrollView底部位置值。我的要求是在加載頁面時,滾動位置必須顯示在頁面的底部。如何在React Native中找到ScrollView for Android的底部位置
您可以通過以下方式完成此操作:它會爲您提供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。
它正在爲我工作。謝謝 :) –