更改活动可以用下面的代码:活动导航:与popEnter自定义动画和popExit样片段与动画
Bundle animation = ActivityOptions.makeCustomAnimation(App.getContext(), R.anim.enter_from_right, R.anim.exit_to_left).toBundle();
startActivity(intent, animation);
对于片段,你可以做FragmentTransaction类似的事情:
// ...
transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
// ...
这工作! 但是我想在按下时弹出一个动画(从后台弹出)。 对于片段只需添加2动画资源(popEnter & popExit):
transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
如何创建相同的“背动画”的活动?
我用这个代码的退出动画:'overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out) ;'你可以在[GmailAnimation](https://github.com/CabezasGonzalezJavier/GmailAnimation)或[LopeAnimations](https://github.com/CabezasGonzalezJavier/LopeAnimations)中看到这些例子。你也可以在这个[Blog]中看到更多(http://thedeveloperworldisyours.com/android/gmail-overriding-pending-transition/#sthash.CEhJwJLg.dpbs)。 – Cabezas
我已经用同样的例子回答了我的问题,但扩展了一点;-) –