【发布时间】:2018-05-11 23:45:36
【问题描述】:
我想改变<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'
}
});
这是这段代码的结果。
我找到了几个小时的答案,但没有任何帮助。
我不确定为什么高度样式不起作用。
感谢任何帮助。
【问题讨论】:
标签: react-native react-native-flatlist