I have an Android fragment question.

Asked 2 years ago, Updated 2 years ago, 20 views

http://itpangpang.xyz/114 While studying the fragment, I felt that what I felt after following the example on the site was like a frame layout, but I don't know if the example is a little insufficient to understand the fragment.

Anyways I want to know the difference between fragment and frame layout.

android

2022-09-22 08:28

1 Answers

Fragments have a life cycle similar to activities, unlike frame layouts. Additionally, the frame layout cannot directly receive information about whether the activity is paused or the screen is rotated, but the fragment can handle it directly. You can also run previous fragments to manage history because the fragment transactions are managed by activity when the user presses the back button. And unlike the frame layout, the UI may exist within the activity as a worker who does not exist.

Frame layouts, on the other hand, are part of a view group provided by Android. Because it is one of the embodiments of how to deploy child views, it is more meaningful to look for differences from Linear Layout, Relative Layout, etc. rather than a direct comparison with fragments.

In addition to the difference between the fragments and the frame layout I described, it would be helpful to read about the background of Android's introduction of the concept of fragments. Please refer to Design Philosophy and the contents of the preceding part of the document below.


2022-09-22 08:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.