Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal scroll some part of ListView column

I want to horizontally scroll some part of a ListView in React Native.

How can I fix the position of first column and make other column horizontally scrollable?

like image 563
SooCheng Koh Avatar asked Jul 06 '16 20:07

SooCheng Koh


1 Answers

The renderRow of ListView should have a Text followed by a horizontal ScrollView.

<ListView
dataSource={this.state.dataSource}
renderRow={this.renderRow}
/>

renderRow (rowData) {
  return (
  <View>
    <Text>rowData.field1</Text>
    <ScrollView horizontal={true}>
      <Text>rowData.field2</Text>
      <Text>rowData.field3</Text>
      <Text>rowData.field4</Text>
    </ScrollView>
  </View>
}

Note the horizontal=true prop in ScrollView which will make it happen.

like image 186
vijayst Avatar answered Oct 03 '22 07:10

vijayst