我想显示一个Dialogfragment,它出现在我的Activity的SharedElement中。我尝试过SharedElementTransition并且无效。这是代码:
FragmentManager fm = this.getSupportFragmentManager();
AddHistoryFragment mAddHistoryFragment = new AddHistoryFragment();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mAddHistoryFragment.setSharedElementReturnTransition(TransitionInflater.from(
this).inflateTransition(R.transition.change_image_trans));
mAddHistoryFragment.setExitTransition(TransitionInflater.from(
this).inflateTransition(android.R.transition.fade));
mAddHistoryFragment.setSharedElementEnterTransition(TransitionInflater.from(
this).inflateTransition(R.transition.change_image_trans));
mAddHistoryFragment.setEnterTransition(TransitionInflater.from(
this).inflateTransition(android.R.transition.fade));
fm.beginTransaction().add(mAddHistoryFragment,"add History")
.addSharedElement(ivAddExpense, ivAddExpense.getTransitionName()).commit();
}else {
mAddHistoryFragment.show(fm, "History");
}
谢谢
答案 0 :(得分:2)
replace
片段事务,但DialogFragment.show()
使用add
事务。
另外,看到这个问题,也许它的解决方案对你有用 Android - Shared Element Transition In Dialog