如何在React Native中找到ScrollView for Android的底部位置(How to find the bottom position of the ScrollView for Android in React Native)
如何在React Native for android中找到ScrollView底部位置值。 我的要求是在加载页面时,滚动位置必须显示在页面底部。
How to find the ScrollView bottom position value in React Native for android. My requirement is while loading the page, scroll position have to show in bottom of the page.
最满意答案
您可以通过以下方式执行此操作:它将为您提供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> ); };我在这里建立了一个工作示例。
You can do this in the following way : it'll give you the height of the 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> ); };I've set up a working example here.
更多推荐
发布评论