ActivityGroup switch view with animation
Asked Answered
F

1

6

So I have this ActivityGroup in which I show 2 Activities. When I'm switching I want to have this transition effect, the current view sliding to the left out of the screen, the new view coming in from the right. This is my code for switching, assuming current view is viewA:

Intent i = new Intent(this, ViewA.class);
viewB = getLocalActivityManager().startActivity("viewb", i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
setContentView(viewB);

Now when I do the following, the background of viewB gets shown, and the contents of viewB slide in, this is not what I want:

Animation animIn = AnimationUtils.loadAnimation(this, R.anim.righttoleftin);
viewB.startAnimation(animIn);
Animation animOut = AnimationUtils.loadAnimation(this, R.anim.righttoleftout);
viewA.startAnimation(animOut);

setContentView(viewB);

How can I achieve this?


Actually, the above does work. I had a problem where I thought viewA was shown, while it was not.

Finnie answered 2/9, 2011 at 12:25 Comment(0)
K
0

here take a look at this

the only drawback it can only be done in XML.

Hope this helps

Kiel answered 6/1, 2012 at 8:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.