views:

640

answers:

4

I'm animating a an ImageView from the left to the right of the screen using a translate animation. The ImageView is place inside a RelativeLayout over the top of my main layout using FrameLayout.

When I run the animation on the emulator everything works pretty well but when I use run it on my G1 it leaves visual artifacts behind and effects the rendering of the text component behind it.

Is this a performance issue and I'm being too ambitious or is it a bug I can overcome?

If it is a performance issue is there anything I can do to improve things?

+1  A: 

Without actually seeing the problem is sounds like you're not clearing the display buffer before writing the next frame. It doesn't sound like a performance issue to me.

Do you have control over whether the device does double buffering or not?

Given that it works on the emulator this could point to either a problem with the emulator or a bug in your code that isn't showing up on the emulator (which I suppose is technically a problem with the emulator!) rather than a performance issue.

ChrisF
I'm using the animation framework provided by the Android framework so I have neither control over the double buffering or the display buffer.To me it looks like a bug. If this were a performance issue because my requirements were too ambitious the animation should just be jerky/have a low framerate. It performs reasonably well, it just leaves what look like pieces of the image behind it. They're cleaned up fairly quickly but it doesn't look good.
Tom Martin
@Tom - I think I've reached the limit of what I can suggest. I don't really know the environment you're developing in - but I do know animation having worked with real time 3D graphics for a number of years and I've encountered similar sounding problems. But as I said, without actually seeing what's going on it's difficult to diagnose the problem.
ChrisF
A: 

I would suggest using a SurfaceView for animation. It is double-buffered, so it should eliminate flickering if you use it properly. If you want an example, the LunarLander demo included in the sdk shows this really well. Also, if you have a more specific question with code, ask away.

As for general Android performance, it is very possible to have reasonably high frame rates, so you aren't expecting too much.

AdamC
+2  A: 

I now this may be a little old, but I just found this:

http://groups.google.com/group/android-developers/browse_thread/thread/5481450f8b71a26c/e750730b9953d9a8?lnk=gst&q=animation+leaves+trails#e750730b9953d9a8

Not sure what android version your using, but it may be a bug in the android libraries!

Looks like that's what the problem is for me! :)

... Dontcha just love it when its not your fault! :D

Andy
Almost certainly. No longer have the code to retest though :( I gave up on that animation and went with one that wouldn't leave a trail.
Tom Martin
A: 

This is happening to me as well. I'm using an emulator using 1.6 with the Google APIs, and I just confirmed that it happens on a Nexus One running FRF83. Here's the relevant code:

Animation a = new TranslateAnimation(0.0f, 0.0f, 100.0f, 0.0f);
a.setDuration(2000);
this.myView.startAnimation(a);

Here's the relevant code for instantiating the view:

View v = new View(this.getApplication());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 80);
v.setLayoutParams(params);
v.setBackgroundColor(0xFFFF0000);
//
LinearLayout layout = (LinearLayout)this.findViewById(R.id.theLayout);
layout.addView(v);
//
v.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
        // TODO Auto-generated method stub
        doAnimation();
    }
});
//
myView = v;

So basically, the double buffering etc, is being handled by the OS, and I have no control over it at all.

fnerg