我正在使用此动画为 LinearLayout 设置动画,但我无法让它移动动画结束的方向...
TranslateAnimation intro = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.8f );
我现在有这段代码可以让它到正确的位置,但它不起作用:
myLinearLayout.setLayoutAnimationListener(
new AnimationListener() {public void onAnimationEnd(Animation animation) {
float pixelsInDP = (float) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT );
int marginLeft = (int) (41 * pixelsInDP);
int marginTop = (int) ((letter1+3) * pixelsInDP);
layoutParams.setMargins( marginLeft, marginTop, 0, 0);
myLinearLayout.setLayoutParams(layoutParams);
myLinearLayout.invalidate();
}
myLinearLayout 是 LinearLayout,但由于某种原因,linearlayout 的位置不会改变...... 我在这里做错了什么?
编辑:经过更多的测试,我发现 onAnimationEnd 事件根本没有被触发......什么......?