Android应用中怎么自定义一个圆形进度条-创新互联

这期内容当中小编将会给大家带来有关Android应用中怎么自定义一个圆形进度条,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

成都创新互联公司服务项目包括岳池网站建设、岳池网站制作、岳池网页制作以及岳池网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,岳池网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到岳池省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

A.绘制圆环,圆弧,文本

//1.画圆环
//原点坐标
float circleX = width / 2;
float circleY = width / 2;
//半径
float radius = width / 2 - roundWidth / 2;
//设置画笔的属性
paint.setColor(roundColor);
paint.setStrokeWidth(roundWidth);
paint.setStyle(Paint.Style.STROKE);
canvas.drawCircle(circleX, circleY, radius, paint);
//2.画圆弧
RectF oval = new RectF(roundWidth/2,roundWidth/2,width-roundWidth/2,width - roundWidth/2);
paint.setColor(roundProgressColor);
canvas.drawArc(oval, 0, progress * 360 / max, false, paint);
//3.画文本
paint.setTextSize(textSize);
paint.setColor(textColor);
paint.setStrokeWidth(0);
String text = progress * 100 / max + "%";
Rect bounds = new Rect();
paint.getTextBounds(text, 0, text.length(), bounds);
canvas.drawText(text, width / 2 - bounds.width() / 2, width / 2 + bounds.height() / 2, paint);

当前标题:Android应用中怎么自定义一个圆形进度条-创新互联
网站链接:http://myzitong.com/article/cesggi.html