So I have this ActivityGroup in which I show 2 开发者_如何学PythonActivities. 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.
here take a look at this
the only drawback it can only be done in XML.
Hope this helps
精彩评论