vis*_*kar 1 animation android fragment
我有一个 android 应用程序,我在其中单击按钮从一个片段加载另一个片段
Fragment fragment = new EditImagesFragment();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction tran = fragmentManager.beginTransaction();
tran.setCustomAnimations(R.anim.push, R.anim.pop);
tran.replace(R.id.content_frame, fragment).addToBackStack(null).commit();
Run Code Online (Sandbox Code Playgroud)
我有推和弹出(滑入和滑出)类型的动画定义如下
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:propertyName="x"
android:valueFrom="1000"
android:valueTo="0"
android:valueType="floatType" />
</set>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:propertyName="x"
android:valueFrom="0"
android:valueTo="-1000"
android:valueType="floatType" />
</set>
Run Code Online (Sandbox Code Playgroud)
现在,当我加载片段时,它会按预期滑入,但是当我按下后退按钮并尝试返回时,滑出动画不起作用,我支持 v14 及以上 API 级别。任何人都可以发现问题吗?
谢谢
尝试
setCustomAnimations(int enter, int exit, int popEnter, int popExit)
代替
setCustomAnimations(int 进入,int 退出)
根据Android 文档,从返回堆栈弹出时不会播放进入和退出动画。
| 归档时间: |
|
| 查看次数: |
2805 次 |
| 最近记录: |