Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to create circle view with Android?

I am creating a View as below design here (like apple music).

pic 1:

pic 2:

The pink circle with physical interaction and fly. Can you suggest ways to make them?

like image 814
Nam Vạc Avatar asked Jul 07 '15 09:07

Nam Vạc


2 Answers

Indeed, you should take a look at the custom view documentation.

What you should do to obtain such a result is to first override the onDraw() method in order to make your custom drawing inside. Using the canvas, you will be able to create circle by calling :

canvas.drawCircle(x, y, radius, paint);

In order to make the circles look as you want, just take a look at the Paint documentation. You can create as much circle as you want (the app efficiency is, of course, affected by the number of circle you draw).

With your custom view, you will be able to handle interactions easily, through the onTouchEvent() and to animate the circle modifying their properties over time.

like image 180
David Peicho Avatar answered Oct 19 '22 01:10

David Peicho


You need to write own View as documented here https://developer.android.com/training/custom-views/index.html and then in your onTouchEvent() check if tap is inside or outside of area you consider checkable (in this case inside the given radius).

like image 28
Marcin Orlowski Avatar answered Oct 19 '22 01:10

Marcin Orlowski