@ohos.arkui.node (Custom Node)

The Node module provides level-2 module APIs of custom nodes to export and use.

  • BuilderNode module: provides APIs for creating a BuilderNode – a custom node that can be used to mount native components. Avoid mounting a BuilderNode as a child node to other custom nodes.

  • FrameNode module: provides APIs for a FrameNode, which represents an entity node in the component tree. It can be used by a NodeController to mount a BuilderNode (that holds the to FrameNode) to a <NodeContainer> or mount a RenderNode to another FrameNode.

  • NodeController module: provides APIs for managing custom nodes, such as creating, showing, and updating custom nodes, and APIs for mounting custom nodes to a <NodeContainer> component.

  • Graphics module: provides APIs for defining attributes of a custom node.

  • RenderNode module: provides APIs for creating a RenderNode in custom drawing settings with C APIs.

  • XComponentNode module: provides APIs a XComponentNode – a <XComponent> in the component tree. You can write EGL/OpenGL ES and media data and display it on the <XComponent>, whose rendering type can be dynamically modified.

NOTE

The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Custom nodes are not available in DevEco Studio Previewer.

Obtaining UI Context

To obtain the UI context, use any of the following methods:
1. Call getUIContext() in ohos.window to obtain the **UIContext **instance.

  1. Call the built-in method getUIContext() of the custom component.

  2. Use the makeNode callback of NodeController.

Modules to Import

import {
  BuilderNode,
  NodeController,
  FrameNode,
  RenderNode,
  XComponentNode,
  NodeRenderType,
  RenderOptions,
  DrawContext,
  Size,
  Offset,
  Position,
  Pivot,
  Scale,
  Translation,
  Matrix4,
  Rotation,
  Frame
} from "@ohos.arkui.node";