I\'m using an xml defined animation to slide a view off the screen. The problem is, as soon as the animation completes it resets to its original position. I need to know how
This problem has bothered for more than a week. And Muhammad's answer pointed me a strightforward way to solve it.
I used sever layout to implement side menus with animation. "view.layout will not be persistent. You should use LayoutParams, which will be persistent."
Here's my solution: (Use what kind of LayoutParameter is depended on your own parent's layout):
@Override
public void onAnimationEnd(Animation animation) {
FrameLayout.LayoutParams layoutParams=new FrameLayout.LayoutParams(screenWidth, screenHeight);
layoutParams.setMargins((int) -(screenWidth * RATE), 0,
(int) (screenWidth - screenWidth * RATE), screenHeight);
for(View v:views) {
v.setLayoutParams(layoutParams);
//v.layout((int) -(screenWidth * RATE), 0, (int) (screenWidth - screenWidth * RATE), screenHeight);
v.clearAnimation();
}
}