Tut*_*utu 6 android react-native react-native-android
在我们的React-native项目中,我们有一个屏幕,它有一个父Scrollview(带有pull to refresh),在scrollview中我们有Listview(作为chilld视图).
在iOS中,我们可以滚动Scrollview(父级)以及Listview(子视图).
但在android中,我们无法滚动Child Listview.当我们尝试滚动子Listview时,父视图将滚动.儿童视图没有获得触摸.
这与React-native问题有关吗?谁能告诉我如何解决这个问题?
代码段:
<ScrollView contentContainerStyle={styles.contentContainerStyle} refreshControl={this.getRefreshControl()}>
<View> Some header </View>
<MyComponent> </MyComponent>
<ListView /* This list view is not scrolling in Android */
dataSource={dataSource}
initialListSize={10}
renderRow={this.renderRow}
renderSeparator={this.renderSeparator}/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我已经做了一个 ListView,如果你愿意的话,它是可以滚动的!
ListBillScreen.js
export default class ListBillScreen extends React.Component{
/*Constructor*/
render() {
return (
<ScrollView style = {styles.container}>
<View style ={styles.header}>
<Text style = {styles.textHeader}> Title</Text>
</View>
<ListView
style={styles.listView}
dataSource={this.state.dataSource}
renderRow={(data) => <Row {...data} navigator={this.props.navigator} />}
renderSeparator={(sectionId, rowId) => <View key={rowId} style=
{styles.separator} />}
/>
<AndroidBackButton
onPress={this.popIfExists.bind(this)}
/>
</ScrollView>
);
Run Code Online (Sandbox Code Playgroud)
} }
风格
import { StyleSheet } from 'react-native'
import { Colors, Metrics } from '../../Themes'
export default StyleSheet.create({
container: {
paddingTop: 20,
backgroundColor: Colors.background
},
separator: {
height: StyleSheet.hairlineWidth,
backgroundColor: '#8E8E8E',
},
textHeader: {
color: Colors.steel,
textAlign: 'center',
},
image: {
height:64,
width: 64,
},
listView: {
paddingTop: 10,
paddingBottom: 20
},
actionButtonIcon: {
fontSize: 20,
height: 22,
color: 'white',
},
})
Run Code Online (Sandbox Code Playgroud)
即使您添加一些行,它也是完全可滚动的 =) (我的行是使用 Json 文件和Row.js创建的)
享受 !
| 归档时间: |
|
| 查看次数: |
6520 次 |
| 最近记录: |