tania
tania

Reputation: 1086

android complex graphic element

button in the middle; animated element around

Good day, I would like to ask for some advice on coding up one pretty strange graphical element.

The point is - there should be a button in the middle (green), but it should be surrounded with an animated element (blue strip around green button on a sketch).

So when user clicks the button, the blue element starts rotating, when he taps again, it stops.

any ideas on that? thanks!

Upvotes: 2

Views: 116

Answers (2)

stamanuel
stamanuel

Reputation: 3819

you could make use of the Animation features of android.

make the green button as ImageButton and the blue ring as static drawable. then create an RotateAnimation which you toggle with the button press. this animation then rotates the drawable that contains the blue ring.

here is something about the rotate animation http://developer.android.com/reference/android/view/animation/RotateAnimation.html

Upvotes: 1

Gabe Sechan
Gabe Sechan

Reputation: 93688

Easiest way is a custom view, where you overwrite onDraw to draw exactly what you want to the canvas. Rotation can be done by keeping track of how many radians of rotation you want and using a rotation matrix on the canvas. Animation can be done by using a Handler to post a delayed message to invalidate the view.

Upvotes: 1

Related Questions