I have two linear layouts which I want to perform two different animation on both of these layouts and at the same time.
Now its working in sequential manner. i.e, after completing one its starting another.
here is my code.
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(500);
inFromRight.setInterpolator(new AccelerateInterpolator());
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoLeft.setDuration(500);
outtoLeft.setInterpolator(new AccelerateInterpolator());
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.menu:
mainLayout.startAnimation(outtoLeft);
sideBar.startAnimation(inFromRight);
break;
}
}
outtoLeft.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mainLayout
.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT, 40));
}
});