从动画backstack Android的流行音乐片段 [英] Android pop fragment from backstack with animation
问题描述
我有一个加载片段的在它的活动。片段A包含ListView和上单击列表项,当我在的地方片段A的加载另一个片段B展现ListView项的详细信息。按钮点击pressing设备后退按钮我它加载previous片段是一个片段显示的ListView。所有这一切工作正常,但我想加载片段A与回preSS或按一下按钮动画。我做它通过这种方式,但不工作:
FragmentManager FSM = getSupportFragmentManager();
FragmentTransaction ftransaction = fsm.beginTransaction();
ftransaction.setCustomAnimations(R.anim.enter_from_left,R.anim.enter_from_left);
fsm.popBackStack();
ftransaction.commit();< XML版本=1.0编码=UTF-8&GT?;
<设置的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:shareInterpolator =假> <翻译
机器人:时间=700
机器人:fromXDelta = - 100%
机器人:fromYDelta =0%
机器人:toXDelta =0%
机器人:toYDelta =0%/>
< /集>
< XML版本=1.0编码=UTF-8&GT?;
<设置的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:shareInterpolator =假> <翻译
机器人:时间=700
机器人:fromXDelta = - 100%
机器人:fromYDelta =0%
机器人:toXDelta =0%
机器人:toYDelta =0%/>< /集>
如果你想backstack动画,你需要使用:
<一个href=\"http://developer.android.com/reference/android/app/FragmentTransaction.html#setCustomAnimations(int,%20int,%20int,%20int)\">setCustomAnimations(int进入,退出INT,INT popEnter,诠释popExit)
是这样的:
setCustomAnimations(R.anim.enter_from_left,R.anim.enter_from_left,
R.anim.exit_to_left,R.anim.exit_to_left);
I have an activity that loads a Fragment A in it. Fragment A contains ListView and when clicking on list item I load another Fragment B in place of Fragment A to show the listview item details. On button click and pressing device back button I it loads the previous fragment which is Fragment A that shows ListView. All this is working fine but I want to load Fragment A with animation on backpress or on button click. I am doing it in this way but not working:
FragmentManager fsm = getSupportFragmentManager();
FragmentTransaction ftransaction = fsm.beginTransaction();
ftransaction.setCustomAnimations(R.anim.enter_from_left, R.anim.enter_from_left);
fsm.popBackStack();
ftransaction.commit();
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="700"
android:fromXDelta="-100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<translate
android:duration="700"
android:fromXDelta="-100%"
android:fromYDelta="0%"
android:toXDelta="0%"
android:toYDelta="0%" />
</set>
If you want backstack animations you'll need to use:
setCustomAnimations(int enter, int exit, int popEnter, int popExit)
Something like:
setCustomAnimations(R.anim.enter_from_left, R.anim.enter_from_left,
R.anim.exit_to_left, R.anim.exit_to_left);
这篇关于从动画backstack Android的流行音乐片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!