Truong Vu
Truong Vu

Reputation: 204

How to draw interlocking circle use canvas in android

I have a issues that: i want to draw an olympic logo with 5 circle, but it need to interlocking with each others. Thanks enter image description here

Not like this: enter image description here

Upvotes: 0

Views: 214

Answers (2)

NSimon
NSimon

Reputation: 5287

Let's have a look at what you want then.

First, you'll need to create a custom View in order to override the onDraw method.

This is where you will draw your circles.

To draw a circle on a canvas, you will use

drawCircle(float cx, float cy, float radius, Paint paint)

Where cx : position X of the center cy : position Y of the center radius : the radius of the circle paint : the paint you'll be using to draw your circle

Now for your paint, you'll just have to create a new one, set its color paint.setColor(Color.RED) As well as the style of the paint : paint.setStyle(Paint.Style.Stroke) Eventually the stroke width and other style you'd like to have.

With all of this, you should be able to work your way through what you want to achieve.

Upvotes: 1

Yev Kanivets
Yev Kanivets

Reputation: 1800

The easiest way to draw an olympic logo is to use high quality png image. But if it is inappropriate for you there is more harder way - you need to draw not circles on canvas, but arcs. You have to calculate all sizes for those arcs and scale them to fit your views.

Upvotes: 1

Related Questions