我的代码是:
<View style={{...styles.tableRow, backgroundColor: index % 2 == 1 ? "#F0FBFC" : "white"}}>
<View style={styles.checkboxContainer}>
<Checkbox label="" color="success" checkboxStyle={styles.checkbox}/>
</View>
<Text style={styles.columnRowTxt}>{members[item].first}</Text>
<Text style={styles.columnRowTxt}>{members[item].last}</Text>
<Text style={styles.columnRowTxt}>{item.Weight}</Text>
</View>
我正在尝试将复选框对齐在该 View 的中心。我最初是在没有风景的情况下尝试的。这是我的风格:
checkbox: {
backgroundColor: "yellow",
},
checkboxContainer: {
flexDirection: "row",
width: "25%",
backgroundColor: "gray",
alignItems:"center"
}
我也尝试过: 复选框:{ 背景颜色:“黄色”, 对齐 self :“居中”, },
如何使其居中?
最佳答案
alignItems: "center"
应该是:
justifyContent: "center"
justifyContent 与 flexDirection 一致,alignItems 与 flexDirection 相反。
关于css - 将 View 中的复选框居中对齐 (RN),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71243704/