0

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.

1 Answer 1

1

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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.