我正在尝试创建根据变量所假定的某些值而改变颜色的几何形状(圆形)。
理论上,我设置了这些几何形状的值,以使它们最终变成圆形,而不是正方形。你能告诉我为什么吗?
this.state = {
pressColorDx1: "",
//...
}
//....
if (this.pressDx_p1 >= 10) { this.setState({ pressColorDx1: "#00438c" }) }
else { this.setState({ pressColorDx1: '#afeeee' }) }
render() {
return (
//..
<View style={{width: 15,height: 15,borderRadius: 15/2,backgroundColor: this.state.pressColorDx1,right: 30, top: 40}}></View>
)}
这应该是一个圆形,但显示为正方形。
这不是top
和right
的问题。我也尝试了b orderRadius: 50%
,但它不起作用。