I want to implement an animation for a fragment on my activity.
But regular startAnimation() method isn’t applicable to fragment.
How can I set an animation to my fragment?
The following is my snippet:
Fragment listview = (Fragment)getSupportFragmentManager().findFragmentById(R.id.my_tab_fragment);
final Animation a = AnimationUtils.loadAnimation(this, R.anim.translate);
To animate the adding/removing of a fragment you should use :
You should have a look at FragmentTransaction documentation .
Just be carefull and call the
setCustomAnimation()method, beforeadd(fragment)orreplace(fragment)on yourFragmentTransaction.