views:

27

answers:

0

I have a Test Application with an empty main layout except for 2 buttons on the screen, next and previous.

I have two custom views called MyView1 and MyView2 that extends View.

They are animated to slide in and out using a custom animation class.

Currently I have been playing with something like the following:

when "previous" is clicked

myView2.startAnimation(AnimClass.outToLeftAnimation());
mainLayout.removeView(myView2);
myView1.startAnimation(AnimClass.inFromRightAnimation());
mainLayout.addView(myView1, 0);

(and vice versa for the next button)

The problem I have is that although it is technically working fine, the views that are shifting in and out are drawn on top of the buttons for the layout (mainLayout, defined in the xml R.layout.main), and then when they stop animating they pop behind like they should be, but i want it to stay behind. How can I fix this?

EDIT: As per the request, this is an example of one of the animations from my AnimClass, they all use the standard built in stuff.

    public static Animation inFromRightAnimation() {

    Animation inFromRight = new TranslateAnimation(
    Animation.RELATIVE_TO_PARENT,  +1.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());
    return inFromRight;
}

EDIT2: Solved. I added a FrameLayout to my main.xml at a lower z-index to the buttons and then moved the views in and out of that.