reactjs - 反应本机文本换行
问题描述
目前我正在开发一个反应原生应用程序。我有文本换行的问题,但是文本会换行,因此有时一行中的最后一个单词会溢出容器,即使最后一行还有空间。我该如何解决?
import { Text, View, Dimensions, StyleSheet } from "react-native";
const TextCard = () => {
const emojy = "Sonne";
const header = "Solarenergie unterstützen";
const content =
"Damit unterstützt du eines der vielen Solarprojekte von Atmosfair auf der ganzen Welt";
const footer = "Schon ab 6€ 260kg CO2 pro Jahr binden";
return (
<View style={styles.container}>
<Text>{emojy}</Text>
<View style={styles.textContainer}>
<Text style={styles.headerText}>{header}</Text>
<Text style={styles.contentText}>{content}</Text>
<Text style={styles.footerText}>{footer}</Text>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
backgroundColor: "#CCC",
width: Dimensions.get("screen").width * 0.85,
height: 130,
borderRadius: 20,
paddingHorizontal: 20,
flexDirection: "row",
alignItems: "center",
marginVertical: 10,
},
contentText: {
fontWeight: "500",
fontSize: 14,
color: "#444",
},
footerText: {
fontWeight: "300",
fontSize: 14,
color: "#777",
},
headerText: {
fontWeight: "600",
fontSize: 16,
color: "#444",
},
textContainer: {
marginLeft: 20,
height: "100%",
justifyContent: "space-evenly",
},
});
export default TextCard;
解决方案
像这样改变你的textContainer
风格。
textContainer: {
marginLeft: 20,
height: "100%",
justifyContent: "space-evenly",
flexDirection: "row",
flex: 1,
flexWrap: "wrap"
}
推荐阅读
- java - Swagger 生成的 JAX-RS 服务器因 ElasticSearch 依赖而中断
- vb.net - 命名空间错误等
- python - 删除较旧的孤立快照 - 脚本
- ios - 取消选择时如何停止 UITableViewCell 闪烁为白色?
- python - 关于 CMD Manifest.json 和 python 文件
- angular - Ngrx 商店组织
- html - 纯CSS中的可折叠文本高度
- html - 电子邮件中的表头在 iOS 中的画外音(ADA)中宣布两次(仅第一列宣布两次)
- django - 如何在Django内部重定向html页面?
- javascript - 如何将值(项目)从一个 Netsuit 业务系统表单自动传输到另一个 Netsuit 表单?