アニメーション化しようとしているメニューがあります。マージンを変更して新しいメニューを挿入することで、メニューを分割しています。メニューを挿入したいときのアニメーションは次のとおりです。
level3Height = level3Frame.getHeight();
final int newBottomMargin = (int)(origBottomMargin + level3Height/2);
final int newTopMargin = (int)(origTopMargin + level3Height/2);
splitUp = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) btnShopWireless.getLayoutParams();
params.bottomMargin = (int)(newBottomMargin * interpolatedTime);
btnShopWireless.setLayoutParams(params);
}
};
joinDown = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) btnShopWireless.getLayoutParams();
params.bottomMargin = (int)(origBottomMargin * interpolatedTime);
btnShopWireless.setLayoutParams(params);
}
};
splitUp.setDuration(1000);
splitUp.setInterpolator(new BounceInterpolator());
joinDown.setDuration(500);
joinDown.setInterpolator(new BounceInterpolator());
挿入されたメニューの高さを取得した後、アニメーションはビューを非常にうまく上に移動します。
btnShopWireless.startAnimation(splitUp);
すべてうまくいきます!しかし....
挿入されたレベル メニューを削除して下に移動したい場合は、以下を使用しますが、アニメーションは発生しません。ビューはスムーズな動きをせずに、元の場所に単純に戻ります。
btnShopWireless.startAnimation(joinDown);
setVisibility を VISIBLE onAnimationStart に設定し、setVisibility を GONE onAnimationEnd に設定する AnimationListeners を設定しました。彼らは仕事をしているので、アニメーションが呼び出されているか、joinDown の AnimationListeners 内で可視性が発生しないことがわかります。しかし、アニメーション化された動きの後退は決して起こりません。最初の splitUp しかアニメートできません。
2番目のアニメーションを機能させるために何が欠けているのか、誰にも手がかりがありますか?