我想改变<FlatList />
的宽度和高度.
我将height
样式设置为当前的<FlatList />
,但它从未起作用.
我绝对不能改变<FlatList />
的高度.
这是我的render()
种功能和风格.
render() {
const listData = [];
listData.push({ key: 0 });
listData.push({ key: 1 });
listData.push({ key: 2 });
listData.push({ key: 3 });
listData.push({ key: 4 });
return (
<View style={styles.container}>
<FlatList
data={listData}
renderItem={({item}) => {
return (
<View
style={{
width: 30, height: 30, borderRadius: 15, backgroundColor: 'green'
}}
/>
)
}}
horizontal
style={styles.flatList}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white'
},
flatList: {
height: 50,
backgroundColor: 'red'
}
});
这就是这个代码的结果.
我花了几个小时才找到答案,但什么都帮不了我.
我不知道为什么身高风格不起作用.
感谢您的帮助.