Hi,



On Sun, Jul 26, 2009 at 9:13 AM, az9702 <[email protected]> wrote:

>
> Hi,
>
> I would like to implement a simple animation using View
>
> The animation involves drawing  a rectangle (w =20px, h =10px)  moving
> from left to right at a 10px increment.
>
> I have two questions:
>
> (1) As the rect moves along, the previous drawing needs to be erased
>     so the rect appears moving along.
>
>     My implementation erases by painting the previous rect with
>     background color.  This works but doubles the drawing.
>
>     Is there a more efficient way of erasing previous rect ?
>
> (2) A time delay is also required between two drawings to show
> successive
>      movement. Without the delay, only the final rect  will appear
> drawn.
>
>      My view class implements Runnable & has a Handler.
>      The run method updates the Rect location & invalidates.
>      I have a draw method that puts in the delay, like so:
>
>      public void draw() {
>        for(int i =0; i<20; i++) {
>            handler.postDelayed(this, i*1000);  //1 sec per drawing
>        }
>    }
>
> (1) & (2) cause the rect to go from left to right in 10px increment on
> 1-sec interval.
>
> As the animation is simple, I would like to use View (not SurfaceView
> or Animation) and it's OK to do all the work in UI thread.
>
> Is there a more efficient way than the one described above to
> implement this simple animation ?
>
> Suggestions & comments are appreciated.
>
> Thanks.
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to