Thanks for the response, but maybe I should mention that I'm trying to
make a game here, so one of the big things is that I'm going to have a
lot of bitmaps interacting with each other and their positions a lot.
Given that extra knowledge, doesn't it make sense to use a Canvas?

On Jan 24, 4:59 pm, Romain Guy <[email protected]> wrote:
> Hi,
>
> Views can be added to a ViewGroup. All layouts (LinearLayout,
> FrameLayout, etc.) are ViewGroups and offer the addView() method. From
> your message, I feel like you are taking a complicated approach. It's
> actually pretty simple:
>
> Create a layout (let's say a FrameLayout)
> Create an ImageView
> Set your AnimationDrawable as the ImageView's image
> Put the image view inside the FrameLayout
> Set the FrameLayout as the content view
>
> There is no need to use a Canvas or to call a system service. Several
> example in ApiDemos show how to use addView() btw.
>
>
>
> On Sat, Jan 24, 2009 at 4:53 PM, Brendan <[email protected]> wrote:
>
> > Ok, all I'm trying to do is figure out how to create a working
> > AnimationDrawable in the code without XML. Can it really be that hard?
> > I continue to run into issues with examples that are not complete
> > enough (the samples provided in the SDK don't even have comments other
> > than the copyright notice most of the time) and documentation that is
> > out of date.
>
> > So the first thing I tried was just to make an AnimationDrawable, add
> > frames to it, draw it to the canvas once a loop, and start it. But
> > wait, turns out there's a bug with starting it within the same context
> > as when the Activity starts. So I wait until the window gets
> > focus...still only the first frame appears. I begin investigating and
> > see that maybe I have to add the AnimationDrawable to an ImageView, so
> > I do that and draw the ImageView to the canvas...and it's no better.
> > Now I'm thinking that the ImageView I added it to has to be added as a
> > child view to the actual view so I'm trying to figure out how to do
> > that. My first guess was just to do a view.addView(ImageView) but that
> > method doesn't exist (although I've seen it referenced a bunch of
> > places). This leads me to find out about the ViewManager, which
> > actually has an addView method. The official documentation page for it
> > () even says: "To get an instance of this class, call
> > Context.getSystemService(http://code.google.com/android/reference/
> > android/view/ViewManager.html)." But guess what?
> > Context.getSystemService() needs a string for an argument, and
> > although there are string constants for all sorts of managers to grab
> > (http://code.google.com/android/reference/android/content/
> > Context.html#getSystemService(java.lang.String) guess which one isn't
> > included in the list? That's right, the ViewManager.
>
> > AAAAAAAHHHHHHHHHHHHHHHHH!
>
> > I've run out of ideas. Seriously, is this documentation incredibly out
> > of date? Is AnimationDrawable just broken? I've tried everything I can
> > think of.
>
> > If anybody can just provide a simple example of how to get frame-by-
> > frame animation up and running it would be greatly appreciated.
>
> > Full disclosure: I posted previously about this same thing with some
> > code (http://groups.google.com/group/android-developers/browse_thread/
> > thread/46f0b91c8af70e4a) but no one has responded.
>
> --
> Romain Guy
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support.  All such questions should be posted on
> public forums, where I and others can see and answer them
--~--~---------~--~----~------------~-------~--~----~
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