Problem starting animation on a View

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Problem starting animation on a View

Postby keianhzo » Sun Nov 01, 2009 2:36 pm

Hi everybody,

I'm having problems trying to start an animation on a custom View that belongs to a custom ViewGroup. If i start the animation on the parent ViewGroup using:

viewgroup.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade));

it works fine and I can see the children views fading out, but if I try to start the same animation directly on the children, nothing happens, the onDraw method is not called.

I guess it might be related to the methods I've overrided in the ViewGroup parent class, but I can't find the way out. The overrided methods are:
- onLayout(): I'm overriding it but i do nothing there because I'm positioning the views in a different manner.
- onSizeChanged()
- onMeasure()
- dispatchDraw(): Here i draw all the children using getChildAt(i).draw(canvas);

Any idea of what could be happening here?
Thanks!
keianhzo
Freshman
Freshman
 
Posts: 3
Joined: Sun Nov 01, 2009 2:07 pm

Top

Postby keianhzo » Mon Nov 02, 2009 6:33 pm

Hi again,

I answer my own question in case someone suffers from the same problem in the future.

I was overriding the dispatchDraw() method to call the draw method of the children view. This was provoking duplicate calls to the children's draw() method on one side and weird results (like not playing the animation) on the other as I was not calling super.dispatchDraw().
So unless you have something interesting to do in the dispatchDraw() method of the ViewGroup class, there's no point on overriding it.
keianhzo
Freshman
Freshman
 
Posts: 3
Joined: Sun Nov 01, 2009 2:07 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests