【发布时间】:2019-05-21 19:47:06
【问题描述】:
我正在尝试在 react-native 中创建一个带有标题和正文的卡片视图。但是,我想为标题添加背景颜色但无法做到。
我能够创建带有标题标题的卡片视图,但无法添加覆盖整个标题部分的背景颜色。 有关我要实现的示例,请参见附加的图像。 如您所见,卡片视图有一个摘要标题,标题/标题部分有灰色背景。标题下方是包含卡片视图内容的正文。我想在 react-native 中实现相同的功能。有人可以帮忙吗?提前致谢
//This is an example of Card View//
import React from 'react';
//import react in our code.
import { Text, View, StyleSheet } from 'react-native';
//import all the components we are going to use.
import { Card } from 'react-native-elements';
//import Card
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Card title="Local Modules">
{/*react-native-elements Card*/}
<Text style={styles.paragraph}>
This is a card from the react-native-elements
</Text>
</Card>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
paddingTop: 40,
backgroundColor: '#ecf0f1',
},
paragraph: {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
color: '#34495e',
},
});
【问题讨论】:
-
这里有什么问题?当您使用
container和paragraph样式时,请为header:{backgroundColor: /* color you want */,}添加另一个样式
标签: react-native