如何在React Native中找到ScrollView for Android的底部位置(How to find the bottom position of the ScrollView for

编程入门 行业动态 更新时间:2024-10-22 11:21:50
如何在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.

更多推荐

本文发布于:2023-08-01 13:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1357963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   中找到   如何在   Native   React

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!