This section describes how to use the three-layer architecture, breakpoint listening and adaptive layout to adapt a set of code in the news & reading app across different devices, such as bar phones, foldable devices, tablets, and PCs Currently, this app is compatible with the following devices: bar-type phones, widescreen foldable devices, bi-fold devices, tri-fold devices, tablets, and PCs.
Before reading this topic, you are advised to learn the ArkUI framework and the capabilities of one-time development for multi-device deployment.
The following practices will focus on these product forms and provide examples from the perspectives of UX design, project management, and mobile/PC page development, helping you develop news & reading apps that can be deployed on multiple devices.
For details about the UX design of the news & reading apps, see the design guide for news & reading apps. The app uses a single-column vertical layout on bar-type devices, a dual-column grid layout on foldable devices and tablets, and a split-view layout of a sidebar plus content area on PCs. The following figure shows the multi-device news reading UI on different devices.

To ensure the reusability and maintainability of the project to implement one-time development for multi-device deployment, it is recommended that developers use a layered architecture to organize code projects. The architecture consists of three layers: common (common capability layer), features (basic feature layer), and products (product customization layer). Each layer has clear responsibilities, providing developers with a clear, efficient, and scalable design architecture. For details about the layered architecture design, see Layered Architecture Design.
You are advised to create a template project after learning how to create and configure a layered architecture project by referring to Cross-Device Project Deployment and Release. Then, modify the project based on the development requirements of the news & reading app to ensure that the project architecture meets the actual service requirements.
When creating a project, you may encounter the problem of how to divide the project structure directory. Considering the reusability and maintainability of the project, this topic uses the news & reading app as an example to provide a recommended solution for reference.
The HarmonyOS project architecture uses a tiered architecture encompassing three layers: product customization layer, basic feature layer, and common capability layer. It provides a clear, efficient, and scalable design architecture. For details, see the logical design in Layered Architecture Design.
The news & reading app organizes its directories based on the three-layer project architecture of common, features, and products. The design of each layer is as follows:
The project structure is as follows:
├──common // Common capability layer
│ └──src/main/ets
│ ├──components // Common UI components (such as NewsCard)
│ ├──constants // Public constants (such as breakpoints)
│ ├──types // Data contract APIs
│ └──utils // Utilities such as windows, breakpoints, and logs
├──features // Basic feature layer
│ ├──recommendation // Home page recommendations
│ │ └──src/main/ets
│ │ ├──constants // Recommended constants
│ │ ├──model // Recommended data
│ │ ├──page // Recommended home page
│ │ ├──view // Home page UI components
│ │ └──viewmodel // Home page status
│ └──newsdetail // News details
│ └──src/main/ets
│ ├──constants // Details constants
│ ├──model // Details data
│ ├──view // UI component of the details page
│ └──viewmodel // Details page status
└──products // Product customization layer
├──default // Default product (bar-type phone/foldable devices/tablet)
│ └──src/main/ets
│ ├──defaultability // Default entry ability
│ └──pages // Pages (home page and details)
└──pc // PC product
└──src/main/ets
├──pages // PC pages
├──pcability // PC entry ability
├──view // PC title bar component
├──viewmodel // PC view model
└──window // PC window management This section describes how to use layout capabilities to adapt a set of pages in the news & reading app across different devices, such as bar-type phones, widescreen foldable devices, bi-fold devices, tri-fold devices, and tablets. In addition, this section describes the window adaptation solutions for the preceding devices, as well as the interaction and function development of each page.
The multi-device news & reading example provides the full-screen, split-screen, floating window, and freeform window modes for different devices. For details, see Window Mode. The split-screen and floating window modes can be easily accessed through the system without any special design. By monitoring window size changes, the app refreshes the UI based on the breakpoints to automatically apply layouts suitable for distinct window modes, such as the full-screen, split-screen, floating window, and freeform window modes.
You can set the window orientation of your app by using setPreferredOrientation(). For a news & reading app, set the Orientation parameter to FOLLOW_DESKTOP so that the app rotates with the desktop. With this rotation policy, on bar-type phones, only the portrait mode is recommended. On large screens, such as bi-fold (unfolded), tri-fold (unfolded), and tablets, rotation in four orientations controlled by the rotation switch in Control Panel is recommended. For details, see Controlling the Display Orientation Using Window Properties.
For better visual experience, the status bar at the top of news & reading apps is usually set to be globally immersive. You can implement the immersive windows in different modes (full-screen, split-screen, and floating window modes) based on the UX design. For details, see Immersive Window. You can implement the immersive windows in full-screen, split-screen, and floating window modes using setWindowLayoutFullscreen() and dynamically avoid the safe area.
The recommendation page on the home page contains multiple content blocks, such as the hot news, hero carousel, text above image widget, and news list. On bar-type phones, these blocks are arranged vertically in a single column. On foldable devices in unfolded state and tablets, these blocks are displayed in a dual-column grid, and the display and hiding of summaries needs to be controlled. Additionally, the arrangement of the search bar and sub-tab bar at the top needs to switch with the horizontal breakpoint.
Below shows the effects on different devices.
Horizontal/Vertical Breakpoint | sm/md | sm/lg | md | lg, xl |
Home page - Recommendation page |
|
|
|
|
UI Development
The following table describes the details and implementation solution of each area on the recommendation page of the mobile home page.
No. | Area | Implementation |
|---|---|---|
1 | Top tab and search box | Use the GridRow component to implement this feature. At different horizontal breakpoints, implement the top-down or left-right layout of the search box and tab by setting the span and order of GridCol. For bar-type phones, the search box occupies the entire row and is above the tab. For PuraX cover screens or when the horizontal breakpoint is md or higher, the tab is placed on the left of the search box. |
2 | Hot news | Use the List component to implement this feature. Use the lanes attribute to set columns based on the breakpoint. Implement one-column layout when the breakpoint is md, two-column layout when it is md, and three-column layout when it is lg or xl. |
3 | Hero carousel | Use the Swiper component to implement this feature. Use the displayCount attribute to set the number of displayed items based on the breakpoint. Display one item when the breakpoint is sm, two items when it is md, and three items when it is lg or xl. |
4 | Text above image widget | Use the Column component to vertically arrange the title and multiple images to create a widget with text above the image. Display one item when the horizontal breakpoint is sm or md, and display two items side by side using the Row component when the breakpoint is lg or xl. |
5 | News list | Display the news list in a single column when the horizontal breakpoint is sm, and use the GridRow component to display the news list in two columns when the breakpoint is md or higher. |
6 | Bottom/Side tab | Use the HdsTabs component to implement this feature. Configure the bar floating style and immersive light effect for the bar. Devices that do not support this effect will automatically degrade. |
The news details page consists of the article and comment area. On bar-type phones, the article and comment area are arranged vertically. On large-screen devices, they are displayed side by side, and the comment area is at the sidebar that can be scrolled independently. The immersive light effect is used for the bottom floating toolbar on devices running API 26 or later. On devices running earlier versions, the background is blurred.
Horizontal/Vertical Breakpoint | sm/md | sm/lg | md | lg, xl |
News Details Page |
|
|
|
|
UI Development
The following table describes the details and implementation solution of each area on the mobile news details page.
No. | Area | Implementation |
|---|---|---|
1 | News title and author area | Use the Column component to vertically arrange the news title and author row. In the author row, use the Row component to horizontally arrange the profile picture, name, release time, and follow button. Adjust the padding based on breakpoints. |
2 | Content area | The text and text are displayed in scrolling mode using the Scroll component. On small screens, the content area is vertically stacked with the title and comment area. When you scroll on the small screen, these parts move together. |
3 | Comment area | Use the List component to display the comment list. When the horizontal breakpoint is md or higher, the comment area is placed in the sidebar on the right of the SideBarContainer component and moves independently when you scroll on the screen. When the horizontal breakpoint is sm, the comment area is stacked below the text. |
4 | Bottom floating toolbar | Use the Stack component to float the toolbar above the content. For API 26 and later, use the systemMaterial() method to implement the immersive light effect. For earlier versions, use the backgroundBlurStyle() method for degradation and blurring the background. |
This section describes how to reuse the code logic and layout based on the existing mobile UI development solution to efficiently develop news & reading apps for PCs. Most of the interaction logic of news & reading apps on PCs is similar to that on mobile devices. This section only describes the differences.
News & reading apps support full-screen and freeform window modes on PCs. For details, see Window Mode. By using responsive components within the app, the layout can automatically adapt to the window size in both full-screen and freeform window modes.
According to the UX design specifications, the immersive effect needs to be implemented in both full-screen and freeform window modes. For details, see Immersive Window. In full-screen mode, the immersive effect is implemented by calling window.setWindowLayoutFullscreen(). In freeform window mode, the title bar is hidden by calling window.setWindowDecorVisible(), and only the three buttons in the upper right corner are retained. In this way, the page content extends to the title bar area, achieving an immersive display effect.
On the home page of the PC, the tab bar is displayed on the left, and the content area is displayed on the right. The following figure shows the effect.

UI Development
The layout of the recommendation page on the home page for the PC is basically the same as that for mobile devices. The page mainly consists of the following areas:
No. | Area | Implementation |
|---|---|---|
1 | Immersive title bar | Use window.setWindowLayoutFullscreen() to make the content occupy the title bar area, and window.setWindowDecorVisible() to hide the default decoration. Use the Stack component to implement the layout. The app icon and name are displayed on the left, and the top tab, plus sign (+) button, and search box are placed on the right, avoiding the three-button area. |
2 | Left tab bar | Set vertical to true for the left HdsTabs component to display the tab bar vertically. |
3 | Content area | The layout is the same as that on mobile devices at the xl breakpoint. For details about the implementation solution, see the recommendation page on the home page for mobile devices. |
On the PC news details page, the news content is displayed on the left, the comment area is displayed on the right, and the toolbar is embedded at the bottom. The running effect is shown in the figure.

UI Development
The layout of the news details page for the PC is basically the same as that for mobile devices. The page mainly consists of the following areas:
No. | Area | Implementation |
|---|---|---|
1 | Content area | The left part has the same layout as that for mobile devices at the xl breakpoint. For details about the implementation, see the news details page for mobile devices. |
2 | Functional area at the bottom | The function buttons are placed horizontally at the bottom of the content area as an embedded toolbar, which is part of the normal layout and does not float to block content. |
3 | Comment area | The right part has the same layout as that for mobile devices at the xl breakpoint. For details about the implementation, see the news details page for mobile devices. |