我正在尝试使用以下代码实现上述背景:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#dddddd" />
<size android:width="0dp" android:height="0dp" />
<stroke
android:width="3dp"
android:color="#aaaaaa" />
<corners
android:bottomLeftRadius="0.1dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="0.1dp"
android:topRightRadius="15dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<solid android:color="#6bb726" />
<size android:width="3dp" android:height="0dp" />
</shape>
</item>
</layer-list>
但是,设置矩形宽度似乎不起作用,绿色矩形占用的空间与灰色矩形一样多。
有人可以建议改进我的xml定义的形状吗?
答案 0 :(得分:1)
尝试这样的事情:
int testCol (int board[3][3]){//test cols for win
int b = 0;
int c = 0;
for (b = 0; b < 3; b++){
if (board[0][b] == 1 && board[1][b] == 1 && board[2][b] == 1){//test player 1
return 1;
cout << "I work" << endl;
break;
}
else if(board[0][b] == 2 && board[1][b] == 2 && board[2][b] == 2){//test player 2
return 2;
break;
}
else{//if none are true return no win
return 0;
}
}
}
编辑:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="15dp">
<shape android:shape="rectangle" >
<solid android:color="#6bb726" />
<size android:width="3dp" android:height="0dp" />
</shape>
</item>
<item android:left="5dp" >
<shape android:shape="rectangle">
<solid android:color="#dddddd" />
<stroke
android:width="3dp"
android:color="#aaaaaa" />
<corners
android:bottomLeftRadius="0.1dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="0.1dp"
android:topRightRadius="15dp" />
</shape>
</item>
</layer-list>