Animation of a View

by Eddified » Thu, 10 Sep 2009 04:54:40 GMT

Sponsored Links
 I understand that animating a View using startAnimation() with a
TranslateAnimation object really just applies a transform on the
canvas that is being drawn on. In my case, the problems with this are:
a) sometimes I need to call bringChildToFront() (for a different View)
on the ViewGroup during the animation, which messes up the animation
because it triggers a requestLayout on all children, which in turn re-
lays out the child being animated... which messes up the continuity of
the animation. Perhaps causing a layout on the child being animated
isn't supposed to mess up animations, but it seems to be in my case.
b) after the animation (using an AnimationListener), I need to re-
layout the child to the new location, which is fine in concept, but
again messes up the animation because for some reason the actual
drawing of the last frame of the animation hasn't finished by the time
onAnimationEnd() is called. This causes the animation to go awry at
the very end. What's happening in my case is if I layout the animated
view to its new location in onAnimationEnd, the last step of the
animation is being applied to the new layout, so the view looks like
it is jumping around the screen. I tried a handler with no delay, and
that didn't work either. Using a handler with a delayed message to
accomplish the new layout works but is such a hack that I worry it may
not work correctly on another piece of hardware.

I could accomplish the animation by taking out the TranslateAnimation
and instead do a manual animation, and in the manual one, change the
layout of the view gradually (instead of transforming the matrix of
the canvas) but that's a lot of work and error-prone.

Any ideas? Are there tools I can use (besides manual application of
Handler.sendMessageDelayed()) to accomplish an animation that actually
re-lays out the view on each iteration instead of altering the canvas

Animation of a View

by Eddified » Thu, 10 Sep 2009 05:09:36 GMT

 another problem:
c) if something changes and I need to reverse the animation from it's
current half-way state, without completing the animation and without
simply clearing it, I don't see any way to accomplish this using the
Animation classes.

Given these problems, what approach should I take?


Sponsored Links

Other Threads

1. Looking for a generic simple demo of getting mobile phone ID and their x, y position data

I am looking for a generic simple demo of getting mobile phone ID and
their x, y position data and sending these to the server.




2. Static variables and NullPointerExceptions...

Actually 1 and 2 are the things to deal with; 3 is not really relevant.  (It
would be if the app had all of its activities finished before going in the
background, then when coming back into the foreground the new activity
instance doesn't have a saved state.  So functionally the same starting the
first time, and not interesting.)

You can provoke this behavior in your app either by using DevTools to set
the maximum number of background process tiny so your process gets killed
nearly immediately, or just use the shell's "ps" and "kill" to find your
process after going in the background and killing it.

As a design pattern, activities shouldn't have dependencies between each
other.  They should always be self-contained separable components.  If you
want to share state between them (which perfectly reasonable) a good way to
do this is to have a separate class of your own managing the state, which is
a singleton.  Then each activity retrieves the singleton when it needs it,
and it will always get initialized when needed (and not before when it is

> > > 

3. Setting an Intent extra value that's an array of String and Integer

4. To get Responce is date

5. Support for JUint Annotation

6. Market Enabler --- Was Better keyboard

7. Android Wiigo untuk Bandung beli di mana ya?