私のカスタム TranslateAnimation は、ビューを垂直に移動します。最初に変な短いちらつき以外は問題ありません。ビューが予期しない位置で点滅したのは、目に見えるフレームが 1 つだけのようです (アニメーションが開始するよりもはるかに高い位置)。
注: super(0,0,0,0) を呼び出してもちらつきは発生しませんが、アニメーションはありません。
ここに私のコードの短いバージョンがあります:
public class ExTranslateAnimation extends TranslateAnimation implements AnimationListener
{
private View myView;
public ExTranslateAnimation (...)
{
// delta is how much it gets moved
super(0, 0, -delta, 0);
this.setAnimationListener(this);
this.setDuration(duration);
toY = view.getTop() + delta;
myView = view;
}
@Override
public void onAnimationEnd(Animation animation)
{}
@Override
public void onAnimationRepeat(Animation animation)
{}
@Override
public void onAnimationStart(Animation animation)
{
LayoutParams lp = (LayoutParams) myView.getLayoutParams();
lp.leftMargin = toX;
lp.topMargin = toY;
myView.setLayoutParams(lp);
myView.layout(toX, toY, 0, 0);
}
}