Android空心圆及层叠效果实现代码
本文实例为大家分享了Android空心圆及层叠效果的具体代码,供大家参考,具体内容如下
packagecom.bwei.test.zidingyiview2; importandroid.content.Context; importandroid.graphics.Canvas; importandroid.graphics.Color; importandroid.graphics.Paint; importandroid.util.AttributeSet; importandroid.view.View; publicclassMyViewextendsView{ privateContextmcontext; privatePaintmpaint; publicMyView(Contextcontext){ super(context); } publicMyView(Contextcontext,AttributeSetattrs){ super(context,attrs); } publicMyView(Contextcontext,AttributeSetattrs,intdefStyleAttr){ super(context,attrs,defStyleAttr); this.mcontext=context; } @Override protectedvoidonDraw(Canvascanvas){ super.onDraw(canvas); //得到屏幕宽高 floatwi=canvas.getWidth()/2; floathe=canvas.getHeight()/2; //创建第一个画笔 Paintpa=newPaint(); //上色 pa.setColor(Color.GREEN); //显示圆边 pa.setAntiAlias(true); //设置空心圆环 pa.setStyle(Paint.Style.STROKE); //设置圆环宽度 pa.setStrokeWidth(6); Paintpa2=newPaint(); pa2.setColor(Color.BLUE); pa2.setAntiAlias(true); Paintpa3=newPaint(); pa3.setColor(Color.BLACK); pa3.setAntiAlias(true); //画什么圆 canvas.drawCircle(wi-85,he-85,80,pa2); canvas.drawCircle(wi,he,100,pa); canvas.drawCircle(wi+110,he+110,120,pa3); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。