【发布时间】:2014-11-05 20:18:39
【问题描述】:
我的班级定义如下:
public class Island extends View {
private ShapeDrawable mDrawable;
public Island(Context context) {
super(context);
int width = 50;
int height = 50;
mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.getPaint().setColor(0xff74AC23);
mDrawable.setBounds(0, 0, width, height);
}
public void change() {
mDrawable.getPaint().setColor(Color.BLACK);
}
protected void onDraw(Canvas canvas) {
mDrawable.draw(canvas);
}
当我在对象上调用 change() 时,为什么形状不会改变颜色?谢谢。
【问题讨论】: