gpt4 book ai didi

react-native - Flatlist 不在绝对 View 内滚动?

转载 作者:行者123 更新时间:2023-12-04 12:42:19 29 4
gpt4 key购买 nike

平面列表不在绝对 View 内滚动这里是我的代码,但如果我删除绝对它工作正常

<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>

最佳答案

我遇到了同样的问题,并通过在绝对 View 和具有高度的 FlatList 之间添加一个 View 来解决。
设置 contentContainerStyle到 FlatList 没有用。

前任。

<View style={{position: 'absolute', top: 0, bottom: 0, etc..}}>
<View style={{height: 300}}>
<FlatList
{...props}
/>
</View>
</View>

关于react-native - Flatlist 不在绝对 View 内滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57157607/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com