在Android开发中通过自定义View实现一个圆形进度条-创新互联
这期内容当中小编将会给大家带来有关在Android开发中通过自定义View实现一个圆形进度条,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
站在用户的角度思考问题,与客户深入沟通,找到栖霞网站设计与栖霞网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、成都网站设计、企业官网、英文网站、手机端网站、网站推广、域名申请、网站空间、企业邮箱。业务覆盖栖霞地区。首先来看看自己定义的View
package cn.easymobi.application.bell.common; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; public class ProgressView extends View{ private float fArcNum; private float fMax; private float density; public float getDensity() { return density; } public void setDensity(float density) { this.density = density; } public ProgressView(Context context) { super(context); } public ProgressView(Context context,AttributeSet attrs) { super(context,attrs); } protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); Paint paint=new Paint(); if(fArcNum>0) { paint.setColor(Color.GRAY); paint.setFlags(Paint.ANTI_ALIAS_FLAG); canvas.drawCircle(40*density/2, 40*density/2, 40*density/2, paint); } paint.setColor(Color.YELLOW); paint.setFlags(Paint.ANTI_ALIAS_FLAG); //paint.setStrokeWidth(2); RectF rect=new RectF(0, 0, 40*density, 40*density); canvas.drawArc(rect, -90, fArcNum,true, paint); paint.setColor(Color.BLACK); paint.setFlags(Paint.ANTI_ALIAS_FLAG); canvas.drawCircle(40*density/2, 40*density/2, 40*density/2-5, paint); } public void setProgress(float num) { fArcNum = (num/fMax) * 360; } public float getfArcNum() { return fArcNum; } public void setfArcNum(float fArcNum) { this.fArcNum = fArcNum; } public float getfMax() { return fMax; } public void setfMax(float fMax) { this.fMax = fMax; } }
本文题目:在Android开发中通过自定义View实现一个圆形进度条-创新互联
文章源于:http://azwzsj.com/article/dppeip.html