public class LayoutScatter extends Object
You can use the tool to define a component in an XML file, and then call the parse(int, ohos.agp.components.ComponentContainer, boolean) method to generate a
Component object using this file.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
LayoutScatter.Picker |
Provides a method for checking whether a component can be loaded.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
LayoutScatter |
clone(Context context,
ResourceManager resourceManager) |
Clones a
LayoutScatter object. |
Component |
createComponentElement(String fullClassName,
AttrSet attrSet) |
Instantiates a component based on the fully qualified class name of the component.
|
static LayoutScatter |
getInstance(Context context) |
Obtains a
LayoutScatter object based on the context. |
LayoutScatter.Picker |
getPicker() |
Obtains the component picker.
|
Component |
parse(int xmlId,
ComponentContainer root,
boolean attachToRoot) |
Converts an XML file to a component.
|
void |
setPicker(LayoutScatter.Picker picker) |
Sets a new component picker to replace the existing one.
|
public static LayoutScatter getInstance(Context context)
LayoutScatter object based on the context.context - Indicates the application context.LayoutScatter object used to convert an XML file to a component.public LayoutScatter clone(Context context, ResourceManager resourceManager)
LayoutScatter object.
The new LayoutScatter object is cloned using the transferred Context and
ResourceManager objects.
context - Indicates the Context object of the application.resourceManager - Indicates the ResourceManager object of the application.LayoutScatter object.public Component parse(int xmlId, ComponentContainer root, boolean attachToRoot)
After converting an XML file to a component, you can add the new component to a root component, in which case, the root component is returned. Otherwise, the created component is returned.
xmlId - Indicates the XML file ID.root - Indicates the root component.attachToRoot - Indicates whether to add to a root component.public LayoutScatter.Picker getPicker()
public void setPicker(LayoutScatter.Picker picker)
picker - Indicates the new component picker to set.public Component createComponentElement(String fullClassName, AttrSet attrSet)
fullClassName - Indicates the fully qualified class name of the component to be instantiated.attrSet - Indicates the XML attribute set provided by this instance.