Dori
Dori

Reputation: 18403

Android - Artifacts using Animation

I am having a problem with visual artifacts on the screen when applying the 3D transformation found here. I have changed this so it rotates around the x axis instead of the y. When i do a full 180 rotation (top going away from you at first) im getting single pixel line artifacts at the bottom area (bottom 10-20%) of every other view that this is applied to. I am using a selector as the background of a LinearLayout and then applying this Animation to it. Can anyone think of a quick solution to this issue?

Thanks for any help!

Upvotes: 9

Views: 2061

Answers (2)

slott
slott

Reputation: 3335

I had a similiar problem with a 2D animation where a View is moved off screen (outside parent view). My solution was quite simple. In my custom View I simply invalidate the parent view to have it redrawn at every frame.

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    ((View) this.getParent()).invalidate();
    canvas.drawBitmap(icon, bm_x, bm_y, mPaint);
}

Upvotes: 0

Dori
Dori

Reputation: 18403

Turns out you just have to invalidate the parent view on each animation step. If you have a custom Animation object you can just do this inside Animation.applyTransformation(...)

Upvotes: 11

Related Questions