I’m using this animation to animate a LinearLayout, but I just cant get it to move the direction the animation ends…
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 );
I now have this code to make it go to the right position, but it doesnt work:
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 is the LinearLayout, but for some reason the position of the linearlayout just wont change…
What am I doing wrong here guys?
EDIT: After a bit more testing, I found out that the onAnimationEnd event is not being triggered at all… what the…?
Turns out I had to change
to
Oh so logical… ah well. Now I just gotta fix those margins 😛