Listview doesn't scroll when inside a scrollview
See original GitHub issueNoticed this after upgrading to 0.7.1 from 0.6.
Below is a simple example to reproduce. I noticed it when upgrading my app that has three separate list views inside a scrolling container. List views are set to show all rows, as they’re not expected to be very long. But all three are large enough to go off page.
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
Component,
ListView,
StyleSheet,
Text,
ScrollView,
View,
} = React;
class TestScrollView extends Component {
constructor(props) {
super(props);
let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(["ALABAMA", "ALASKA", "AMERICAN SAMOA", "ARIZONA", "ARKANSAS", "CALIFORNIA", "COLORADO", "CONNECTICUT", "DELAWARE", "DISTRICT OF COLUMBIA", "FEDERATED STATES OF MICRONESIA", "FLORIDA", "GEORGIA", "GUAM GU", "HAWAII", "IDAHO", "ILLINOIS", "INDIANA", "IOWA", "KANSAS", "KENTUCKY", "LOUISIANA", "MAINE", "MARSHALL ISLANDS", "MARYLAND", "MASSACHUSETTS", "MICHIGAN", "MINNESOTA", "MISSISSIPPI", "MISSOURI", "MONTANA", "NEBRASKA", "NEVADA", "NEW HAMPSHIRE", "NEW JERSEY", "NEW MEXICO", "NEW YORK", "NORTH CAROLINA", "NORTH DAKOTA", "NORTHERN MARIANA ISLANDS", "OHIO", "OKLAHOMA", "OREGON", "PALAU", "PENNSYLVANIA", "PUERTO RICO", "RHODE ISLAND", "SOUTH CAROLINA", "SOUTH DAKOTA", "TENNESSEE", "TEXAS", "UTAH", "VERMONT", "VIRGIN ISLANDS", "VIRGINIA", "WASHINGTON", "WEST VIRGINIA", "WISCONSIN", "WYOMING"])
};
}
render() {
return (
<View style={styles.container}>
<ScrollView>
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData) => <Text>{rowData}</Text>}
/>
</ScrollView>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});
AppRegistry.registerComponent('TestScrollView', () => TestScrollView);
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:19 (1 by maintainers)
Top Results From Across the Web
ListView inside ScrollView is not scrolling on Android
I found a solution that works excellently and can scroll the ListView without problems: ListView lv = (ListView)findViewById(R.id.
Read more >[Android] Nested ListView doesn't scroll inner ... - GitHub
When nesting ListViews inside of one another, folks typically set the inner ListView.physics to NeverScrollableScrollPhysics, making only the ...
Read more >How to embed List in ScrollView using SwiftUI
Hi! I want to allow user to scroll a long list of items iOS app, so I am trying to embbed a List...
Read more >listview inside nested scrollview doesn't show the list item ...
OS: macOS Sierra Studio Version: Studio 2.3 RC1 ----- Issue: listview inside nested scrollview doesn't show the list item content. Solution:
Read more >Xamarin Forms Listview in Scrollview doesn't scroll - MSDN
Try to use the Listview inside a Stacklayout and use Listview's header and footer for additional views. How can i make my screen...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same issue as I had the following component structure.
As wrapping the ListView inside the ScrollView the parent scroll action dominates the child scroll action which leads only ScrollView to scroll. I resolved this issue by adding the following code as a prop to the parent View which wraps the ScrollView
Add
scrollEnabled={this.state.enableScrollViewScroll}
prop to ScrollViewAnd Finally add following to the View which wraps the ListView( immediate parent )
this works very well on IOS and Android both, scrolls the ListView if the touch is on List and else it scrolls the ScrollView
@sadafk831 : Could you post a complete code example? I get lost somewhere.