Generalization to 2 views in a fragment transaction

getFragmentManager().beginTransaction().setCustomAnimations(
  R.animator.1, R.animator.2,R.animator.3, R.animator.4)
  .replace(view1, view2)
  .addToBackStack(null)
  .commit();

      

Only animation is performed on view2 . I also want to do something with view1 at the same time. How should I do it? These views are FrameLayouts with a dynamically generated id

+3


source to share


2 answers


Referring to Android Developers: FragmentTransaction setCustomAnimations (int enter, int exit, int popEnter, int popExit)



If I understand clearly what you need, to use animation for 1 view, you must provide the animator with an exit parameter

+2


source


I solved this problem myself. The manager stowed my transaction before I set the animation, so it stacks the transaction without animations (sad but true), and this happens even after I commit the transaction after the setCustom () method.

The solution is to set the animation first:



FragmentTransaction transaction = manager.beginTransaction();       
transaction.setCustomAnimations(view1,view2);
transaction.replace(R.id.content, myFragment);
transaction.commit();

      

0


source







All Articles