【发布时间】:2012-09-11 07:57:08
【问题描述】:
我正在使用 v4 兼容性库并像这样切换到新片段:
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
transaction.replace(R.id.contentFragmentContainer, event.getFragmentClass().newInstance(), FRAGMENT_CONTENT);
transaction.addToBackStack(fragmentTransactionName);
transaction.commit();
现在,当我想以编程方式返回前一个片段而不用新的片段事务污染用户的后台堆栈时,我使用popBackStackImmediate():
if (fragmentManager.popBackStackImmediate(fragmentTransactionName, 0)) {
return;
}
// apparently popping back to that fragment was not successful,
// make a regular transaction now
这一切都很好,尽管用于动画到弹出片段之一的动画没有反转。我也尝试过事先使用transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE),但是当常规交易发生时,这甚至没有显示转换,也没有显示反向。
我做错了什么?
【问题讨论】:
标签: android android-fragments transitions