Sab*_*h.M 8 react-native react-native-ios react-native-flatlist
平面列表不在绝对视图内滚动这是我的代码,但如果我删除绝对它工作正常
<View style={{ flex: 1, marginTop: 8 }}>
<Input ref={input => {
this.input = input;
}}
onFocus={() => {
this.setState({ showPicker: true })
}}
onEndEditing={() => {
this.setState({ showPicker: false })
}}>
</Input>
<View style={{ position: "relative", zIndex: 9999, margin: 8 }}>
{
this.state.showPicker ?
<View style={{position:"absolute",width:"100%", backgroundColor: "white" }}>
<FlatList
data={["A", "B", "C", "D", "E", "F", "G", "H", "A", "B", "C", "D", "E", "F", "G", "H"]}
showsVerticalScrollIndicator={false}
renderItem={({ item }) =>
<TouchableWithoutFeedback>
<View>
<View style={{ width: "100%", height: 50 }}>
<Text style={{ height: "100%", width: "100%" }}>{item}</Text>
</View>
<Divider />
</View>
</TouchableWithoutFeedback>
}
keyExtractor={item => item}
/>
</View> : null
}
</View>
</View>
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,并通过在绝对视图和具有高度的 FlatList 之间添加一个视图来解决。
设置contentContainerStyle为 FlatList 不起作用。
前任。
<View style={{position: 'absolute', top: 0, bottom: 0, etc..}}>
<View style={{height: 300}}>
<FlatList
{...props}
/>
</View>
</View>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4658 次 |
| 最近记录: |