如何绘制圆圈分区中的android? [英] How to draw circle with partitioned in android?

查看:226
本文介绍了如何绘制圆圈分区中的android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要画这种类型的圈子我的应用程序。我能够得出使用画布圈,但我不能获得有关如何使分区的任何想法?

I want to draw this type of circle in my application. I am able to draw circle using Canvas but I can't get any idea about how to make partitioned?

任何人都可以建议我怎么才能让分区圈子?

Can anyone suggest me how can I make partitioned of circle?

编辑: - 我想提请行是内圆

在此先感谢。

推荐答案

这里的工作$ C $下您的要求......

Here's the working code for your requirement....

编辑code: -

    Paint paint1 = new Paint();
        Paint paint2 = new Paint();
        Paint paint3 = new Paint();
        Paint paint4 = new Paint();
        Paint paint5 = new Paint();
        final RectF rect = new RectF();
        int mRadius = 130;
        //Example values
        rect.set(getWidth()/2- mRadius, getHeight()/2 - mRadius, getWidth()/2 + mRadius, getHeight()/2 + mRadius); 
        paint1.setColor(Color.GREEN);
        paint1.setStrokeWidth(mRadius/2);
        paint1.setAntiAlias(true);
        paint1.setStrokeCap(Paint.Cap.BUTT);
        paint1.setStyle(Paint.Style.STROKE);
        paint2.setColor(Color.RED);
        paint2.setStrokeWidth(mRadius/2);
        paint2.setAntiAlias(true);
        paint2.setStrokeCap(Paint.Cap.BUTT);
        paint2.setStyle(Paint.Style.STROKE);
        paint3.setColor(Color.BLUE);
        paint3.setStrokeWidth(5);
        paint3.setAntiAlias(true);
        paint3.setStrokeCap(Paint.Cap.BUTT);
        paint3.setStyle(Paint.Style.STROKE);
        canvas.drawArc(rect, 0, 60, false, paint1);
        canvas.drawArc(rect, 60, 60, false, paint2);
        canvas.drawArc(rect, 120, 60, false, paint1);
        canvas.drawArc(rect, 180, 60, false, paint2);
        canvas.drawArc(rect, 240, 60, false, paint1);
        canvas.drawArc(rect, 300, 60, false, paint2);

        canvas.drawLine(getWidth()/2, 
                getHeight()/2, getWidth()/2-mRadius/2, getHeight()/2-mRadius/2,paint3);

        canvas.drawLine(getWidth()/2, 
                getHeight()/2, getWidth()/2+mRadius/2, getHeight()/2-mRadius/2,paint3);

        canvas.drawLine(getWidth()/2, 
                getHeight()/2, getWidth()/2-mRadius/2, getHeight()/2+mRadius/2,paint3);

        canvas.drawLine(getWidth()/2, 
                getHeight()/2, getWidth()/2+mRadius/2, getHeight()/2+mRadius/2,paint3);

        canvas.drawLine(getWidth()/2, 
                getHeight()/2, getWidth()/2-mRadius/4-mRadius/2, getHeight()/2,paint3);

        canvas.drawLine(getWidth()/2, 
                getHeight()/2, getWidth()/2+mRadius/4+mRadius/2, getHeight()/2,paint3);

        paint4.setColor(Color.BLACK);

        canvas.drawCircle(getWidth()/2, getHeight()/2, mRadius/2, paint4);

        paint5.setColor(Color.YELLOW);
        paint5.setStrokeWidth(3);
        paint5.setAntiAlias(true);
        paint5.setStrokeCap(Paint.Cap.BUTT);
        paint5.setStyle(Paint.Style.STROKE);
        canvas.drawCircle(getWidth()/2, getHeight()/2, mRadius/2, paint5);

我现在希望你满意我的回答......

I hope now you satisfy with my answer....

这篇关于如何绘制圆圈分区中的android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆