这是我的操作步骤。我在res/anim中有一个名为translate.xml的文件,它运行良好,内容如下:
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0%"
android:toXDelta="0%"
android:fromYDelta="0%"
android:toYDelta="10%"
android:repeatCount="0"
android:duration="1000"
android:fillEnabled="true"
android:fillAfter="true"/>
我将代码执行方式如下:
我像这样执行我的代码:
l = (LinearLayout) findViewById(R.id.linearLayout1);
a = AnimationUtils.loadAnimation(this, R.anim.translate);
a.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation anim){};
public void onAnimationRepeat(Animation anim){};
public void onAnimationEnd(Animation anim){
//l.setLayoutParams(params);
};
});
l.startAnimation(a);
当动画完成时,我希望被动画移动的LinearLayout能够移动到它的新位置。这是因为该LinearLayout包含了用户可以互动的多个表单元素。
这是一个相当简单的项目中的一个简单的动画。它只把元素向下移动了约30个像素。如果没有遇到问题,我不会寻求帮助。但是我已经挣扎了几个小时了。我知道需要在动画结束时更新LinearLayout的参数,但具体如何做呢?我看过好几种方法,但都有点令人困惑。
提前感谢您的帮助。