Android 中ShapeDrawable的使用
构造方法:
ShapeDrawable();
ShapeDrawable(Shapes);
作用:
在画布上绘画一些简单的图形,并且管理图形的外观。
publicclassSampleViewextendsView{
privateShapeDrawablemShapeDrawable=null;
publicSampleView(Contextcontext){
super(context);
}
@Override
protectedvoidonDraw(Canvascanvas){
super.onDraw(canvas);
//画背景
canvas.drawColor(Color.WHITE);
//画图形
mShapeDrawable=newShapeDrawable(newOvalShape());
//获得画笔并且绘制图形
mShapeDrawable.getPaint().setColor(Color.GREEN);
//设置x,y,left,top
mShapeDrawable.setBounds(20,60,50,80);
//绘制图形
mShapeDrawable.draw(canvas);
}
}
相关推荐
大地飞鸿 2020-11-12
星星有所不知 2020-10-12
jinxiutong 2020-07-26
MIKUScallion 2020-07-05
songfens 2020-07-05
songfens 2020-06-11
songfens 2020-06-08
northwindx 2020-05-31
northwindx 2020-05-31
northwindx 2020-05-27
northwindx 2020-05-25
MIKUScallion 2020-05-25
jinxiutong 2020-05-10
xdyangxiaoromg 2020-05-10
大地飞鸿 2020-05-06
northwindx 2020-04-25