【发布时间】:2013-09-06 03:42:27
【问题描述】:
我有一个菜单要制作动画。我通过更改边距来拆分菜单 并插入一个新菜单。当我要插入菜单时,动画是:
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);
我将 AnimationListeners 设置为 setVisibility 到 VISIBLE onAnimationStart,并将 setVisibility 设置为 GONE onAnimationEnd。他们正在做他们的工作,所以我知道动画正在被调用,否则在用于 joinDown 的 AnimationListeners 中永远不会出现可见性。但是动画运动的倒退从未发生过。我只能动画第一个,splitUp。
任何人都知道我缺少什么以使第二个动画正常工作吗?
【问题讨论】:
标签: android