Android - Custom Animation on fragment transaction not running

后端 未结 4 880
梦谈多话
梦谈多话 2020-12-12 19:00

I\'m using Google API 8 (Android 2.2) with support package v4.

It doesn\'t give any error or animation.

Transaction:

Fragme         


        
4条回答
  •  臣服心动
    2020-12-12 19:27

    The manager was stacking my transaction before I set the animation, so it stacks the transaction without animations (sad but true), and that occurs even if I commit the transaction after the setCustomAnimations().

    The solution is to set the animations first:

    FragmentTransaction transaction = manager.beginTransaction();       
    transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
    transaction.replace(R.id.content, myFragment);
    transaction.commit();
    

提交回复
热议问题