Android空心圆及层叠效果实现代码-创新互联
本文实例为大家分享了Android空心圆及层叠效果的具体代码,供大家参考,具体内容如下
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、微信小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了徐汇免费建站欢迎大家使用!package com.bwei.test.zidingyiview2; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.view.View; public class MyView extends View { private Context mcontext; private Paint mpaint; public MyView(Context context) { super(context); } public MyView(Context context, AttributeSet attrs) { super(context, attrs); } public MyView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mcontext = context; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // 得到屏幕宽高 float wi = canvas.getWidth() / 2; float he = canvas.getHeight() / 2; // 创建第一个画笔 Paint pa = new Paint(); // 上色 pa.setColor(Color.GREEN); // 显示圆边 pa.setAntiAlias(true); // 设置空心圆环 pa.setStyle(Paint.Style.STROKE); // 设置圆环宽度 pa.setStrokeWidth(6); Paint pa2 = new Paint(); pa2.setColor(Color.BLUE); pa2.setAntiAlias(true); Paint pa3 = new Paint(); 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); } }
网页名称:Android空心圆及层叠效果实现代码-创新互联
URL地址:http://pwwzsj.com/article/didohh.html