Android fragment complete parsing, all you need to know about fragmentation

Source: Internet
Author: User

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.