[android-developers] Lost with custom drawable animation
Hi everyone,
I'm currently developing an application with custom drawables and i'm
kind of lost.
I do not use XML since all kind of the parameters have to be computed
on the fly.
I have a main custom view holding all the gui.
I made a class mcDrawable extending drawable implementing
Drawable.Callback.
In its draw method, i draw a couple of primitive (circles, and so on)
An instance of mcDrawable is displayed via the onDraw method of the
view.
When I trigger a motionEvent in the view, it calls a certain method in
an instance of mcDrawable which modifies the shapes. Since I call an
invalidate() after each event in the view, the drawable is updated
nicely during the motion. So far, all is good.
When I stop the motion (ACTION_UP), it triggers another method in the
instance of mcDrawable which send a message to an Handler in
mcDrawable which animate it by the mean of delayed messages. However,
the View is not aware of these changes and therefore, does not redraw
the drawable.
To achieve the proper behavior, i made the view static, with a
Handler, and send a message from mcDrawable Handler to the one of the
view. When the view receive it, it invalidates. However, I don't think
that its the proper way to achieve this !
So my question is the following: is there a proper way for mcDrawable
to ask the View to redraw it, by the mean of Drawable.Callbacks for
example ? I understand that it may use a selfInvalidate() in
mcDrawable, but I don't understand how to link it to the view. Could
someone help me ?
Thanks !
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home