reactjs - 如何显示一排按钮
问题描述
我正在尝试设置按钮样式,以便它们连续显示。使用下面的代码,按钮出现在一列中。如何实现下图所示的样式?我想使用 Flex
renderRadioButton = () => {
return (
<View
style={{
flexDirection: 'row',
flexWrap: 'wrap',
padding: 0,
margin: 0,
listStyle: 'none',
display: 'flex',
}}
>
<View
style={{
flexDirection: 'row',
flexWrap: 'wrap',
}}
>
<Text
style={{
color: Colors.black,
borderWidth: 1,
borderColor: 'black',
borderStyle: 'solid',
backgroundColor: Colors.green,
width: 50,
height: 50,
fontSize: 6,
textAlign: 'center',
padding: 10,
margin: 10,
marginBottom: 50,
}}
>
TEST
</Text>
</View>
</View>
)
}
解决方案
你想要这样的东西吗?:
<View
style={{
flexDirection: "row",
padding: 0,
margin: 0,
justifyContent: "center",
alignItems: "center"
}}
>
<View>
<Text
style={{
color: "black",
borderWidth: 1,
borderColor: "black",
borderStyle: "solid",
backgroundColor: "green",
width: 50,
height: 50,
fontSize: 6,
textAlign: "center",
padding: 10
}}
>
TEST
</Text>
</View>
<View>
<Text
style={{
color: "black",
borderWidth: 1,
borderColor: "black",
borderStyle: "solid",
backgroundColor: "green",
width: 50,
height: 50,
fontSize: 6,
textAlign: "center",
padding: 10,
}}
>
TEST
</Text>
</View>
<View>
<Text
style={{
color: "black",
borderWidth: 1,
borderColor: "black",
borderStyle: "solid",
backgroundColor: "green",
width: 50,
height: 50,
fontSize: 6,
textAlign: "center",
padding: 10,
}}
>
TEST
</Text>
</View>
<View>
<Text
style={{
color: "black",
borderWidth: 1,
borderColor: "black",
borderStyle: "solid",
backgroundColor: "green",
width: 50,
height: 50,
fontSize: 6,
textAlign: "center",
padding: 10,
}}
>
TEST
</Text>
</View>
<View>
<Text
style={{
color: "black",
borderWidth: 1,
borderColor: "black",
borderStyle: "solid",
backgroundColor: "green",
width: 50,
height: 50,
fontSize: 6,
textAlign: "center",
padding: 10
}}
>
TEST
</Text>
</View>
</View>
推荐阅读
- activemq - ActiveMQ 阻止消费者处理特定消息
- reactjs - 更新firebase数据库后“警告:无法在未安装的组件上调用setState(或forceUpdate)”
- android - Vision BarcodeDetector 不读取数据矩阵条码
- javascript - React - 尝试渲染对象的属性,尽管它保持“未定义”
- linkedin - 尝试从 Linkedin CDN 获取创意图片时出现 403 禁止
- react-admin - React Admin - 可以将产品分配到多个类别吗?
- selenium-webdriver - 如何在 Webdriver 中向 ModalDialog 输入文本
- database - 物化视图 Google BigQuery
- java - 如何在 Java 中从现有的“.inp”文件中运行液压单步仿真
- git - Git 错误:找不到存储库