如何在React Native中找到ScrollView for Android的底部位置

时间:2016-03-04 10:27:29

标签: android react-native

如何在React Native for android中找到ScrollView底部位置值。我的要求是在加载页面时,滚动位置必须显示在页面底部。

1 个答案:

答案 0 :(得分: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