Performing action after fragment transaction animation is finished

前端 未结 5 597
旧巷少年郎
旧巷少年郎 2020-11-30 01:23

I want to set a buttons visibility after the animation is finished.

That\'s what calls the animation:

android.support.v4.app.FragmentTransaction fAni         


        
5条回答
  •  暖寄归人
    2020-11-30 01:41

    Added in API 26 (and in Support Library) you can use

     FragmentTransaction runOnCommit (Runnable runnable);
    

    For example:

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_from_left);
    ft.show(YourFragment);
    ft.commit();
    ft.runOnCommit(() -> Your_Action_Here);
    

提交回复
热议问题