【发布时间】:2015-02-20 09:03:56
【问题描述】:
当用户离开片段时,我会显示动画。为此,我正在使用支持包的setCustomAndimations。
“popEnter”和“popExit”工作正常,但在活动旋转后它们会丢失,
即在没有动画的情况下发生旋转弹出片段之后。
在活动中创建片段:
@Override
protected void onCreate(Bundle savedInstanceState) {
...
if (savedInstanceState == null) { // activity started for the first time, no fragment attached yet
fragment = MyFragment.newInstance(params);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(0, 0, // enter animations, not important here
// when popping fragment -> these are lost on rotation
R.anim.slide_in_right, R.anim.slide_out_right);
ft.add(R.id.content, fragment, MY_TAG).addToBackStack(null).commit();
}
}
有没有办法/解决方法在旋转后保持动画“弹出”片段?
【问题讨论】:
标签: android android-fragments android-animation