我有:
public Button[] getButtons(int buttonCount, List<String> buttonHeaders, Context activity) {
Button[] result = new Button[buttonCount];
for (int i = 0; i < buttonCount; i++) {
result[i] = new Button(activity);
result[i].setId(i);
result[i].setText(buttonHeaders.get(i));
result[i].setBackgroundResource(R.drawable.buttons_shape);
result[i].setBackgroundColor(randomColor(activity));
result[i].setTextColor(activity.getResources().getColor(R.color.white));
result[i].setWidth(360);
result[i].setHeight(100);
}
return result;
}
但是在我的可绘制文件中是这样的:
<solid android:color="@color/white"/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
但我想定义程序的颜色,因为颜色是随机的,当我更改背景时会返回到默认设计(PS. 抱歉我的英语 :P)
但是我希望能够指定程序的颜色,因为这些颜色是随机的。当我更改背景后,程序会回到默认设计(注:抱歉我的英语 :P)。