android - 只有一个视图时需要使用fragment吗
大家讲道理
大家讲道理 2017-04-18 09:04:31
0
7
413

一个activity,整个全部用fragment填充,和直接用activity绘制,占用上有差距吗?如图

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(7)
黄舟

The description of the question is not detailed enough. It can be analyzed from several aspects:

1. View drawing efficiency: There should be no difference
2. Page loading speed: Single Activity is obviously higher than Activity using Fragment, because Fragment requires FragmentManager & ChildFragmentManager to maintain them;
3. Memory overhead: Single Activity is obviously smaller.

The above three points can be verified through the tools that come with the Android development environment.

p.s. @zzxxasp has made it very simple and clear about the usage scenarios of these two.

阿神

If the questioner wants to ask about memory usage, it will definitely take up more than pure activity. After all, there are more memory objects, so there is nothing to say. The key is what your usage scenario is, a view or a direct activity.

Ty80

Activity is more efficient than Fragment. Because Activity can be used alone, but Fragment must be placed in Activity to use. If there is a single view, I think it is better to use the activity directly. If there are multiple switches, such as the 3 buttons under QQ WeChat to switch views, it would be better to use fragments

伊谢尔伦

The purpose of using Fragment is to separate logic to facilitate development and management. If using a single Fragment can make the logic clear and simplify the original Activity code, a single Fragment is not impossible.

Ty80

Just use a separate Activity to save code.

阿神

This depends on the needs. The function of Fragment is to extract and manage the parts of the activity independently. And Fragment has its own life cycle, so it is not that complicated when the functions are subdivided. I have also seen using view before To implement the functions of Fragment.

黄舟

For a cake, is it more expensive to have one layer of packaging box or two layers of packaging box?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template