View.setBackgroundColor(color);
View.setBackgroundDrawable(R.drawable.shape);
通过代码编写shape,或者通过GradientDrawable设置颜色
GradientDrawable myGrad = (GradientDrawable)rectangle.getBackground();
myGrad.setColor(Color.color);
View.setBackgroundColor(color);
View.setBackgroundDrawable(R.drawable.shape);
通过代码编写shape,或者通过GradientDrawable设置颜色
GradientDrawable myGrad = (GradientDrawable)rectangle.getBackground();
myGrad.setColor(Color.color);