Now, I will present the way to resolve this requirement.
1. Create animation (xml) files
After starting a new Android project, in "res/anim" folder, put some animation files in it:
2. Create some layout (xml) files
Activity layout: contains 2 container layouts to replace fragment and adding views:
Fragment layout:
Inflated (child) layout:
3. Code code
In our Fragment, we random a number between [0;100] and show in TextView:
In Activity, we set event listener for 2 buttons which click them, a child layout was added to container layout or a Fragment was replaced (for more details, I commented in code):