Steve
Steve

Reputation: 1636

Slowly Draw A Line In Android

I have a Line class composed of two Points of two ints each that I draw with a wrapper over Canvas.drawLine().

Easy so far.

I want to have that Line drawn slowly from one Point to the other. My best guess is to make a function that will dice up my Line into an list of Lines, starting from the first Point with each subsequent Line getting longer and longer till it reaches from one Point to the other. Then, I will have a Canvas.drawLine wrapper that will take that array of Lines, and iterate over them, drawing each one with a pause of some sort in between them, giving the appearance of the line "growing".

Is there something in the android libraries that already does this and/or would this be better solved some other way?

Edit: This is android 2.1

Upvotes: 2

Views: 1755

Answers (2)

ethan
ethan

Reputation: 790

Android has libraries for creating animations. Look into tweened animations and the AnimationDrawable class.

Upvotes: 4

Mr.Me
Mr.Me

Reputation: 9276

Or maybe you can have one line with a fixed starting point and on each draw the end point increments . I believe this approach has better performance .

Upvotes: 0

Related Questions