progress-画圆弧的时候sweepAngle参数等于135的时候圆弧显示的怪异

作者:用户 来源:互联网 浏览:333 次 时间:2016-03-17 11:54:31

progress-画圆弧的时候sweepAngle参数等于135的时候圆弧显示的怪异 - 摘要: 画圆弧的时候sweepAngle参数等于135的时候圆弧显示的怪异publicclassCircleProgressBarextendsView{privateinthour;privateintma

问题描述

画圆弧的时候sweepAngle参数等于135的时候圆弧显示的怪异

public class CircleProgressBar extends View{

    private int hour;    private int maxProgress = 24;    private int progress;    int progress1;    private int progressStrokeWidth = 32;    RectF oval;    Paint paint;    Paint paint1;    public CircleProgressBar(Context context AttributeSet attrs) {        super(context attrs);        oval = new RectF();        paint = new Paint();        paint1 = new Paint();    }    @Override    protected void onDraw(Canvas canvas){        super.onDraw(canvas);        Calendar c=Calendar.getInstance();        hour = c.get(Calendar.HOUR_OF_DAY);        progress = hour;        int width = this.getWidth();        int height = this.getHeight();        if(width != height){            int min = Math.min(width height);            width = min;            height = min;        }        paint.setAntiAlias(true);        paint.setColor(Color.LTGRAY);        canvas.drawColor(Color.BLACK);        paint.setStrokeWidth(15);        paint.setStyle(Style.STROKE);        oval.left = progressStrokeWidth / 2; // 左上角x        oval.top = progressStrokeWidth / 2; // 左上角y        oval.right = width - progressStrokeWidth / 2; // 左下角x        oval.bottom = height - progressStrokeWidth / 2; // 右下角y        canvas.drawArc(oval -90 360 false paint);        paint.setColor(Color.rgb(0x57 0x87 0xb6));

// paint.setStrokeCap(Paint.Cap.ROUND);

        paint.setColor(Color.CYAN);        canvas.drawArc(oval -90 135 false paint);        paint.setStrokeJoin(Paint.Join.ROUND);        paint.setStrokeWidth(15);        String text = (long)(((float) progress / maxProgress) * 100) + ""%"";        int textHeight = height / 4;        paint.setTextSize(textHeight);        int textWidth = (int) paint.measureText(text 0 text.length());        paint.setStyle(Style.FILL);        canvas.drawText(text width / 2 - textWidth / 2 height / 2 +textHeight/2 paint);    }    public int getMaxProgress() {        return maxProgress;    }    public void setMaxProgress(int maxProgress) {        this.maxProgress = maxProgress;    }    public void setProgress(int progress) {        this.progress = progress;        this.invalidate();    }    /**     * 非UI线程调用     */    public void setProgressNotInUiThread(int progress) {        this.progress = progress;        this.postInvalidate();    }}显示的结果是![](device-2014-12-24-113514.png)
【云栖快讯】你想见的Java技术专家都在这了,向大佬提问,有问题必答  详情请点击
云栖社区(yq.aliyun.com)为您免费提供progress-画圆弧的时候sweepAngle参数等于135的时候圆弧显示的怪异相关信息,包括 sweepangle,sweep angle,sweep,sweep the floor,3 sweep中文版下载的信息 ,所有progress-画圆弧的时候sweepAngle参数等于135的时候圆弧显示的怪异相关内容均不代表云栖社区的意见! 该页面h5页面的地址是:https://m.aliyun.com/yunqi/wenzhang/show_97756,您可以点击progress-画圆弧的时候sweepAngle参数等于135的时候圆弧显示的怪异-手机站访问。
弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率

40+云计算产品,6个月免费体验

现在注册,免费体验40+云产品,及域名优惠!

云服务器9.9元/月,大学必备

热点导航