you can add a fragment in two ways
1 Through the XML
2 Add fragment Run time
Android - Fragments. Advertisements. A Fragment is a piece of an activity which enable more modular activity design. It will not be wrong if we say, a fragment is a kind of sub-activity.