1e41f4b71Sopenharmony_ci# NDK API Overview
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciThe ArkUI framework offers NDK APIs for building UIs with C/C++, including component creation, UI tree control, attribute configuration, and event handling. While ArkTS and the ArkUI declarative framework are recommended for most UI development, use the ArkUI NDK APIs when:
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci- You need to dynamically create and mount UI components for bridging to your own UI framework.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci- You want to enhance UI performance by finely controlling component creation and attributes to reduce latency and handle high loads.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci- You aim to reuse C or C++ UI libraries developed by yourself or others.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ciThe ArkUI NDK APIs provide the following capabilities:
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci- **Layout**
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci  Layout defines the size and position of components on the UI. The ArkUI NDK APIs offer linear, stacking, flexbox, relative layouts, and scrollable and carousel containers.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci- **Component**
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci  Components are essential for UI, shaping the appearance on the screen. They include both built-in system components and custom components with user-defined layout and drawing behaviors. Built-in components, such as buttons, radio buttons, images, and text, can be quickly created and have their attributes and events set using the ArkUI NDK APIs. Customization capabilities for UI components encompass layout measurement and drawing, enabling the construction of distinctive UI components.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci- **Dialog box**
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci  Dialog boxes are vital for UI interactions. ArkUI NDK APIs enable the creation and display of custom dialog boxes with user-defined content.
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci- **Animation**
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci  Animations are one of the key elements of UI. The ArkUI NDK provides explicit animation APIs for crafting property animations that enhance the user experience with efficient and sophisticated effects.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci- **Interaction event**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci  Interaction events are important for interactions between the UI and users. The ArkUI NDK allows users to interact with your application UI, with support for various universal events and gesture events. Universal events include touch events, mouse events, and focus events. Gesture events accept single gestures (tap, long press, pan, pinch, rotation, and swipe), and a combination of gestures.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci## Overall Architecture
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**Figure 1** Relationship between NDK APIs and the ArkTS declarative UI 
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci![en-us_image_0000001923986433](figures/en-us_image_0000001923986433.png)
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci**Figure 2** Schematic diagram of component mounting through NDK APIs 
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci![NDK Access](figures/ndk_access.png)
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci- The ArkTS declarative UI frontend and the NDK APIs both expose ArkUI's underlying capabilities. Compared to the ArkTS declarative UI frontend, NDK APIs not only strip away the declarative UI syntax such as state management but also streamline component capabilities, encapsulating the core functions of ArkUI components through C APIs.
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci- NDK-created UI components must be mounted through ArkTS placeholder components. Once mounted, they coexist with ArkTS components on the same UI tree, following uniform layout and event-handling rules.
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci## How to Develop
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciUsing the NDK for UI development involves the following tasks.
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci| Task| Description|
59e41f4b71Sopenharmony_ci| -------- | -------- |
60e41f4b71Sopenharmony_ci| [Getting Started with the NDK](../napi/ndk-development-overview.md)| Introduces the suitable scenarios and essential knowledge for the NDK.|
61e41f4b71Sopenharmony_ci| [Integrating with ArkTS Pages](ndk-access-the-arkts-page.md)| Explains how to mount the NDK-developed UI onto ArkTS pages for rendering and display.|
62e41f4b71Sopenharmony_ci| [Listening for Component Events](ndk-listen-to-component-events.md)| Describes how to register event listeners for components and add gesture interactions.|
63e41f4b71Sopenharmony_ci| [Using Animations](ndk-use-animation.md)| Introduces how to add animations on the native side.|
64e41f4b71Sopenharmony_ci| [Developing a Long List with Lazy Loading](ndk-loading-long-list.md)| Explains how to develop performant long lists on the native side using lazy loading.|
65e41f4b71Sopenharmony_ci| [Building Dialog Boxes](ndk-build-pop-up-window.md)| Introduces how to build dialog boxes.|
66e41f4b71Sopenharmony_ci| [Building Custom Components](ndk-build-custom-components.md)| Describes how to build custom components with the NDK to achieve unique UI elements.|
67e41f4b71Sopenharmony_ci| [Embedding ArkTS Components](ndk-embed-arkts-components.md)| Explains how to build pages on the native side that include ArkTS components.|
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci## Precautions
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ciWhen using NDK APIs to develop UIs, ensure that all UI API calls are made on the application's main thread to prevent multi-threading issues, which can lead to crashes.
73