离开活动时(之前)如何启动layoutAnimation [英] How can I start layoutAnimation when(before) leaving an activity
本文介绍了离开活动时(之前)如何启动layoutAnimation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的活动中有一个LinearLayout视图。
I have a LinearLayout View in my activity.
当我按下后退按钮时,我希望LinearLayout的子项滑出。
When I press back button I want LinearLayout's children to slide out.
我有以下代码不会执行任何操作:
I have the following code which doesn't do anything:
private void SlideOut()
{
LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(this, R.anim.layout_animation_row_slide_out);
Animation animation=controller.getAnimation();
animation.setFillAfter(true);
LinearLayout menuLayout =((LinearLayout)findViewById(R.id.menuLayout));
menuLayout.setLayoutAnimation(controller);
menuLayout.startLayoutAnimation();
}
@Override
public void onBackPressed(){
//super.onBackPressed();
SlideOut();
}
我已注释掉super.OnBackPressed()来查看动画是否开始,
I have commented out super.OnBackPressed() to see if the animation starts, and it don't start.
有人遇到类似的问题吗?
Somebody with similar problems ?
推荐答案
我认为您可能会在动画制作完成之前退出活动。尝试实现动画监听器
I think you might be exiting the activity before animation is finished. Try implementing Animation Listener
这篇关于离开活动时(之前)如何启动layoutAnimation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文