构造方法:
ShapeDrawable();
ShapeDrawable(Shape s);
作用:
在画布上绘画一些简单的图形,并且管理图形的外观。
ShapeDrawable();
ShapeDrawable(Shape s);
作用:
在画布上绘画一些简单的图形,并且管理图形的外观。
public class SampleView extends View { private ShapeDrawable mShapeDrawable = null; public SampleView(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); //画背景 canvas.drawColor(Color.WHITE); //画图形 mShapeDrawable = new ShapeDrawable(new OvalShape()); //获得画笔并且绘制图形 mShapeDrawable.getPaint().setColor(Color.GREEN); //设置x,y,left,top mShapeDrawable.setBounds(20,60,50,80); //绘制图形 mShapeDrawable.draw(canvas); } }