definition (GoF design mode): Combines objects into a tree structure to represent a hierarchical structure of "partial whole." The combined mode makes the user consistent with the use of individual objects and composite objects.
involves roles
1. Component: (View) is an object declaration interface in a composition that implements the default behavior of all classes common interfaces, where appropriate. Declares an interface for accessing and managing component subassemblies.
2.Leaf: (TextView, Custom view) represents the leaf node object in the composition, and the leaf node has no sub-nodes (that is, you cannot add view within the view).
3.Composite: (ViewGroup and its subclasses) defines a sub-point behavior that is used to store subassemblies and to implement operations related to subassemblies in the component interface, such as increasing (AddView), acquiring (Getviewat), and deleting (Removeview) and so on.
applicability
1. You want to represent the part of the object-the overall hierarchy
2. You want users to ignore the difference between a combined object and a single object, and the user will use all the objects in the composite structure uniformly.
Summarize
(1). Structural mode
(2). Defines a class hierarchy that contains Basic objects and composite objects. This structure provides the flexibility to control the use of basic objects and composite objects.
(3). The base object and the composition object are consistent, and the user does not have to differentiate between them.
(4). Makes it easier to add new types of components.
Please correct me if there is any wrong place to be continued.
Android and design mode--combination (Composite) mode