android - Difficulty reversing fragment animation with backstack -


i trying implement custom animation when changing fragments. custom animation works 1 way , not work when pressed. on press correct fragment shown no animation. code fragment transaction:

fragmenttransaction transaction = getfragmentmanager().begintransaction(); transaction.setcustomanimations(r.anim.slide_in_left, r.anim.slide_out_right, r.anim.slide_in_right, r.anim.slide_out_left); transaction.replace(r.id.frame_container, fragment, fragmenttag); transaction.addtobackstack(null); transaction.commit(); 

my code anim xml files:

//slide in left <?xml version="1.0" encoding="utf-8"?> <set>     <objectanimator xmlns:android="http://schemas.android.com/apk/res/android"         android:propertyname="x"         android:valuetype="floattype"         android:valuefrom="-1280"         android:valueto="0"         android:duration="500"/> </set>  //slide out right <?xml version="1.0" encoding="utf-8"?> <set>     <objectanimator xmlns:android="http://schemas.android.com/apk/res/android"         android:propertyname="x"         android:valuetype="floattype"         android:valuefrom="0"         android:valueto="-1280"         android:duration="500"/> </set>  //slide in right <?xml version="1.0" encoding="utf-8"?> <set>     <objectanimator xmlns:android="http://schemas.android.com/apk/res/android"         android:propertyname="x"         android:valuetype="floattype"         android:valuefrom="-1280"         android:valueto="0"         android:duration="500"/> </set>  //slide out left <?xml version="1.0" encoding="utf-8"?> <set>     <objectanimator xmlns:android="http://schemas.android.com/apk/res/android"         android:propertyname="x"         android:valuetype="floattype"         android:valuefrom="0"         android:valueto="-1280"         android:duration="500"/> </set> 

the code onbackpressed()

@override public void onbackpressed() {     super.onbackpressed(); } 

any ideas i'm going wrong? help

use code onbackpressed:

if (getfragmentmanager().getbackstackentrycount() > 0) {             getfragmentmanager().popbackstack();         } else {             super.onbackpressed();         } 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -