开发者

Android - Artifacts using Animation

开发者 https://www.devze.com 2023-04-11 06:02 出处:网络
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 rot

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 sele开发者_如何学运维ctor 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!


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(...)


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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消