我有:
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)
答案 0 :(得分:0)
你不能同时做两件事。你可以做view.setBackgroundDrawable(drawable);或view.setBackGroundColor(color);