FragmentTransation setCustomAnimations不工作 [英] FragmentTransation setCustomAnimations not working
问题描述
我试图用全新的Android的兼容性包的片段包括到我的项目。 我想有一个过渡动画,当我添加一个新的片段。事情只是我的动画作品之一。将在动画作品,但出动画不能正常工作。 我读的地方,它是在兼容包的错误。但我也读到,修正了该兼容包的第三次修改。谁能帮我解决这个问题。
在动画
<翻译的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:插=@机器人:动画/ anticipate_interpolator
机器人:fromXDelta =0
机器人:toXDelta =0
机器人:fromYDelta =100%
机器人:toYDelta =0%
机器人:时间=1000/>
出场的动画
<翻译的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:插=@机器人:动画/ accelerate_interpolator
机器人:fromXDelta =0
机器人:toXDelta =0
机器人:zAdjustment =顶
机器人:fromYDelta =0%
机器人:toYDelta =100%
机器人:时间=1000/>
这是在code我用添加片段
newFragment =新HelloWorldFragment();
FragmentTransaction英尺= getSupportFragmentManager()的BeginTransaction()。
ft.setCustomAnimations(R.anim.bottom_top_animation,R.anim.top_bottom_animation);
ft.add(R.id.outer_layout,newFragment);
ft.addToBackStack(空);
ft.commit();
本作品在库的当前版本,但它肯定是破previously。你可以使用这样的:
最后FragmentManager FM = getSupportFragmentManager();
最终FragmentTransaction英尺= fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_up,R.anim.slide_down,R.anim.slide_up,R.anim.slide_down)
。新增(R.id.fragment_container,新SomeFragment(),FRAGMENT_TAG)
.addToBackStack(FRAGMENT_TAG)
。承诺();
在这里R.anim.slide_up是你在动画和R.anim.slide_down是你出的动画。第二对PARAMS(3和4)setCustomAnimations允许你指定弹出输入/输出动画弹出的backstack(例如,当用户presses回来,片段将动画废除指定为第四动画参数)。
I trying to use the new android compatibility package to include fragments into my project. I am trying to include a transition animation when I add a new fragment. The thing is only one of my animation work. The In animation works but the Out animation doesn't work. I read somewhere that it is a bug in the compatibility package. But I also read that the bug was fixed in the 3rd revision of the compatibility package. Can anyone help me with this issue
In Animation
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/anticipate_interpolator"
android:fromXDelta="0"
android:toXDelta="0"
android:fromYDelta="100%"
android:toYDelta="0%"
android:duration="1000"/>
Out Animation
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromXDelta="0"
android:toXDelta="0"
android:zAdjustment="top"
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="1000"/>
This is the code I use to add fragments
newFragment = new HelloWorldFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.bottom_top_animation, R.anim.top_bottom_animation);
ft.add(R.id.outer_layout, newFragment);
ft.addToBackStack(null);
ft.commit();
This works in the current version of the library, but it was definitely broken previously. You can use something like this:
final FragmentManager fm = getSupportFragmentManager();
final FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_up, R.anim.slide_down, R.anim.slide_up, R.anim.slide_down)
.add(R.id.fragment_container, new SomeFragment(), FRAGMENT_TAG)
.addToBackStack(FRAGMENT_TAG)
.commit();
where R.anim.slide_up is your in animation and R.anim.slide_down is your out animation. The second pair of params (3 and 4) for setCustomAnimations allow you to specify the pop in/out animations for popping the backstack (e.g., when the user presses back, the fragment will animate away with the animation specified as the fourth param).
这篇关于FragmentTransation setCustomAnimations不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!