简体   繁体   English

带动画的ActivityGroup切换视图

[英]ActivityGroup switch view with animation

So I have this ActivityGroup in which I show 2 Activities. 所以我有这个ActivityGroup,其中我展示了2个活动。 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 : 这是我的切换代码,假设当前视图是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: 现在当我执行以下操作时,将显示viewB的背景,并且viewB的内容会滑入,这不是我想要的:

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. 我有一个问题,我认为viewA被显示,而事实并非如此。

here take a look at this 在这里看看这个

the only drawback it can only be done in XML. 唯一的缺点是它只能用XML完成。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM