我想知道如何在特定页面上复出后重复动画。当您访问某个活动时,我的动画基本上会将 RelativeLayout 向下转换几个像素。但是,如果我然后单击将我发送到不同页面的按钮,然后单击后退按钮返回,则 TranslationAnimation 不会再次启动。这是代码:RelativeLayout r1; r1 = findViewById(R.id.r1); TranslateAnimation a = new TranslateAnimation(0,0,-10f,0); a.setDuration(800); a.setFillAfter(true); r1.startAnimation(a);每次访问我的活动时,我究竟如何让这个动画重新启动?
2 回答
BIG阳
TA贡献1859条经验 获得超6个赞
在活动中制作单独的方法
void myanimation(){
TranslateAnimation a = new TranslateAnimation(0,0,-10f,0);
a.setDuration(800);
a.setFillAfter(true);
r1.startAnimation(a);
}
然后调用活动内部的方法 onResume
@Override
public void onResume(){
super.onResume();
myanimation();
}
添加回答
举报
0/150
提交
取消