In testing my cached theory, I discovered that you need to have at
least two frames for the animation to continuously loop.  When I added
the gauge object again onDraw was continuously called.  That makes me
think that I should be using something else for what I'm doing.

I'm basically making a drawn speedometer getting speeds from the GPS.
Each time the GPS updates I want to perform a smooth animation to the
change in speed.  I thought I could create a Drawable that contained
it's current value and a target value, then add it to an animation
that would take care of calling onDraw continuously until the current
and target matched.  Is there a better way?

On Jul 25, 10:33 am, nkijak <[email protected]> wrote:
> I'm trying to draw a "gauge" on the screen with information from
> various sensors.  I have a class that extends Drawable and a custom
> view that during construction creates a new AnimationDrawable and sets
> the only frame to my custom Drawable.  I then start the
> AnimationDrawable from my Activity onWindowFocusChanged method.  My
> custom Drawable onDraw method is only called once though.  Is that by
> design (as in onDraw is called for each frame once and it's cached and
> shown over and over) or am I doing something wrong?
>
> [code from custom view's constructor]
>         _gaugeAnimation = new AnimationDrawable();
>         _gaugeAnimation.setOneShot(false);
>         setBackgroundDrawable(_gaugeAnimation);
>
>         GaugeDrawable gauge = new GaugeDrawable();
>         gauge.setTargetValue(100);
>         _gaugeAnimation.addFrame(gauge, 500);
>         _gaugeAnimation.setVisible(true, false);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to