We all know that the interface display on Android is done through activity, the activity is too common, I believe we are already very familiar with, here will not repeat.
But activity also has its limitations, the same interface on the mobile phone may look good, on the tablet is not necessarily, because the flat screen is very large, the mobile phone interface on the tablet may be stretched excessively, control spacing too large and so on. The better experience at this time is to embed "small activity" in the activity, and then each "small activity" can have its own layout. So our protagonist, fragment, is on the scene today.
A preliminary study on fragment
In order for the interface to be better displayed on the tablet, Android introduced the Fragment (fragmentation) feature in version 3.0, which is very similar to activity and can include layouts like an activity. Fragment is usually nested within the activity, now imagine the scene: two Fragment,fragment 1 contains a ListView, each row showing the title of a book. Fragment 2 contains TextView and ImageView to display the details and pictures of the book.
If the program is now running in vertical mode on a flat or mobile phone, Fragment 1 may be embedded in an activity, and Fragment 2 may be embedded in another activity, as shown in the following illustration:
And if the program is now running on a flat-screen model, two fragment can be embedded in the same activity, as shown in the following figure: