1e41f4b71Sopenharmony_ci# Linear Layout (Row/Column)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciLinear layout is the most frequently used layout in development, built with the [Row](../reference/apis-arkui/arkui-ts/ts-container-row.md) or [Column](../reference/apis-arkui/arkui-ts/ts-container-column.md) linear containers. The linear layout is the basis of other layouts. Its child elements are arranged in sequence linearly in the horizontal direction, as in a **Row** container, or vertical direction, as in a **Column** container.  
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci  **Figure 1** Child element arrangement in a Column container 
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci![arrangement-child-elements-column](figures/arrangement-child-elements-column.png)
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci  **Figure 2** Child element arrangement in a Row container 
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci![arrangement-child-elements-row](figures/arrangement-child-elements-row.png)
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## Basic Concepts
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci- Layout container: container component that is able to lay out other elements as its child elements. The layout container calculates the size of its child elements and arranges the layout.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci- Layout child element: element inside the layout container.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci- Main axis: axis along which child elements are laid out by default in the linear layout container. The main axis is horizontal for the **Row** container and vertical for the **Column** container.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci- Cross axis: axis that runs perpendicular to the main axis. The cross axis is vertical for the **Row** container and horizontal for the **Column** container.
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci- Spacing: distance between child elements.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci## Spacing of Child Elements in Arrangement Direction
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ciIn the layout container, use the **space** attribute to equally space child elements in the arrangement direction.
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci### In Column Container
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci  **Figure 3** Layout child element spacing in the arrangement direction in the Column container 
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci![arrangement-direction-column](figures/arrangement-direction-column.png)
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci```ts
44e41f4b71Sopenharmony_ciColumn({ space: 20 }) {
45e41f4b71Sopenharmony_ci  Text('space: 20').fontSize(15).fontColor(Color.Gray).width('90%')
46e41f4b71Sopenharmony_ci  Row().width('90%').height(50).backgroundColor(0xF5DEB3)
47e41f4b71Sopenharmony_ci  Row().width('90%').height(50).backgroundColor(0xD2B48C)
48e41f4b71Sopenharmony_ci  Row().width('90%').height(50).backgroundColor(0xF5DEB3)
49e41f4b71Sopenharmony_ci}.width('100%')
50e41f4b71Sopenharmony_ci```
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci![arrangement-direction-column-sample](figures/arrangement-direction-column-sample.png)
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci### In Row Container
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci  **Figure 4** Layout child element spacing in the arrangement direction in the Row container 
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci![arrangement-direction-row](figures/arrangement-direction-row.png)
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci```ts
64e41f4b71Sopenharmony_ciRow({ space: 35 }) {
65e41f4b71Sopenharmony_ci  Text('space: 35').fontSize(15).fontColor(Color.Gray)
66e41f4b71Sopenharmony_ci  Row().width('10%').height(150).backgroundColor(0xF5DEB3)
67e41f4b71Sopenharmony_ci  Row().width('10%').height(150).backgroundColor(0xD2B48C)
68e41f4b71Sopenharmony_ci  Row().width('10%').height(150).backgroundColor(0xF5DEB3)
69e41f4b71Sopenharmony_ci}.width('90%')
70e41f4b71Sopenharmony_ci```
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci![en-us_image_0000001562700509](figures/en-us_image_0000001562700509.png)
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci## Alignment of Child Elements Along Cross Axis
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ciIn the layout container, use the **alignItems** attribute to set the alignment mode of child elements along the cross axis. The alignment performance is consistent across screens of various sizes. The value is of the [VerticalAlign Type](../reference/apis-arkui/arkui-ts/ts-appendix-enums.md#verticalalign) type when the cross axis is in the vertical direction and the [HorizontalAlign](../reference/apis-arkui/arkui-ts/ts-appendix-enums.md#horizontalalign) type when the cross axis is in the horizontal direction.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ciThe layout container also provides the **alignSelf** attribute to control the alignment mode of a single child element along the cross axis. This attribute has a higher priority than the **alignItems** attribute. This means that, if **alignSelf** is set, it will overwrite the **alignItems** setting on the corresponding child element.
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci### Horizontal Alignment of Child Elements in Column Container
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci  **Figure 5** Horizontal alignment of child elements in the Column container 
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci![horizontal-arrangement-child-column](figures/horizontal-arrangement-child-column.png)
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci- **HorizontalAlign.Start**: Child elements are left aligned horizontally.
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci  ```ts
91e41f4b71Sopenharmony_ci  Column({}) {
92e41f4b71Sopenharmony_ci    Column() {
93e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci    Column() {
96e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci    Column() {
99e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
100e41f4b71Sopenharmony_ci  }.width('100%').alignItems(HorizontalAlign.Start).backgroundColor('rgb(242,242,242)')
101e41f4b71Sopenharmony_ci  ```
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci  ![en-us_image_0000001511580964](figures/en-us_image_0000001511580964.png)
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci- **HorizontalAlign.Center**: Child elements are center-aligned horizontally.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci  ```ts
108e41f4b71Sopenharmony_ci  Column({}) {
109e41f4b71Sopenharmony_ci    Column() {
110e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci    Column() {
113e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci    Column() {
116e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
117e41f4b71Sopenharmony_ci  }.width('100%').alignItems(HorizontalAlign.Center).backgroundColor('rgb(242,242,242)')
118e41f4b71Sopenharmony_ci  ```
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci  ![en-us_image_0000001562820897](figures/en-us_image_0000001562820897.png)
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci- **HorizontalAlign.End**: Child elements are right-aligned horizontally.
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci  ```ts
125e41f4b71Sopenharmony_ci  Column({}) {
126e41f4b71Sopenharmony_ci    Column() {
127e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci    Column() {
130e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci    Column() {
133e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
134e41f4b71Sopenharmony_ci  }.width('100%').alignItems(HorizontalAlign.End).backgroundColor('rgb(242,242,242)')
135e41f4b71Sopenharmony_ci  ```
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci  ![en-us_image_0000001511421348](figures/en-us_image_0000001511421348.png)
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci### Vertical Alignment of Child Elements in Row Container
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci  **Figure 6** Vertical alignment of child elements in Row container 
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci![horizontal-arrangement-child-row](figures/horizontal-arrangement-child-row.png)
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci- **VerticalAlign.Top**: Child elements are top-aligned vertically.
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci  ```ts
149e41f4b71Sopenharmony_ci  Row({}) {
150e41f4b71Sopenharmony_ci    Column() {
151e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci    Column() {
154e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci    Column() {
157e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
158e41f4b71Sopenharmony_ci  }.width('100%').height(200).alignItems(VerticalAlign.Top).backgroundColor('rgb(242,242,242)')
159e41f4b71Sopenharmony_ci  ```
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci  ![en-us_image_0000001563060765](figures/en-us_image_0000001563060765.png)
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci- **VerticalAlign.Center**: Child elements are center-aligned vertically.
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci  ```ts
166e41f4b71Sopenharmony_ci  Row({}) {
167e41f4b71Sopenharmony_ci    Column() {
168e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci    Column() {
171e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci    Column() {
174e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
175e41f4b71Sopenharmony_ci  }.width('100%').height(200).alignItems(VerticalAlign.Center).backgroundColor('rgb(242,242,242)')
176e41f4b71Sopenharmony_ci  ```
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci  ![en-us_image_0000001562700505](figures/en-us_image_0000001562700505.png)
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci- **VerticalAlign.Bottom**: Child elements are bottom-aligned vertically.
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci  ```ts
183e41f4b71Sopenharmony_ci  Row({}) {
184e41f4b71Sopenharmony_ci    Column() {
185e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci    Column() {
188e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci    Column() {
191e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
192e41f4b71Sopenharmony_ci  }.width('100%').height(200).alignItems(VerticalAlign.Bottom).backgroundColor('rgb(242,242,242)')
193e41f4b71Sopenharmony_ci  ```
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci  ![en-us_image_0000001563060781](figures/en-us_image_0000001563060781.png)
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci## Arrangement of Child Elements Along Main Axis
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ciIn the layout container, you can use the **justifyContent** attribute to set the arrangement mode of child elements along the main axis. The arrangement may begin from the start point or end point of the main axis, or the space of the main axis can be evenly divided.
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci### Vertical Alignment of Child Elements in Column Container
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci  **Figure 7** Vertical alignment of child elements in the Column container
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci![vertial-arrangement-child-column](figures/vertial-arrangement-child-column.png)
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.Start)**: The items are vertically aligned with each other toward the start edge of the container.
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci  ```ts
212e41f4b71Sopenharmony_ci  Column({}) {
213e41f4b71Sopenharmony_ci    Column() {
214e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci    Column() {
217e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci    Column() {
220e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
221e41f4b71Sopenharmony_ci  }.width('100%').height(300).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.Start)
222e41f4b71Sopenharmony_ci  ```
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci  ![en-us_image_0000001562700501](figures/en-us_image_0000001562700501.png)
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.Center)**: The elements are vertically aligned with each other toward the center of the container. The space between the first component and the start edge is the same as that between the last component and the end edge.
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci  ```ts
229e41f4b71Sopenharmony_ci  Column({}) {
230e41f4b71Sopenharmony_ci    Column() {
231e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci    Column() {
234e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci    Column() {
237e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
238e41f4b71Sopenharmony_ci  }.width('100%').height(300).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.Center)
239e41f4b71Sopenharmony_ci  ```
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci  ![en-us_image_0000001562700517](figures/en-us_image_0000001562700517.png)
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.End)**: The elements are vertically aligned with each other toward the end edge of the container.
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci  ```ts
246e41f4b71Sopenharmony_ci  Column({}) {
247e41f4b71Sopenharmony_ci    Column() {
248e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci    Column() {
251e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci    Column() {
254e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
255e41f4b71Sopenharmony_ci  }.width('100%').height(300).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.End)
256e41f4b71Sopenharmony_ci  ```
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci  ![en-us_image_0000001562940585](figures/en-us_image_0000001562940585.png)
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.SpaceBetween)**: The elements are evenly distributed vertically. The space between any two adjacent elements is the same. The first element is aligned with the start edge, the last element is aligned with the end edge, and the remaining elements are distributed so that the space between any two adjacent elements is the same.
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci  ```ts
263e41f4b71Sopenharmony_ci  Column({}) {
264e41f4b71Sopenharmony_ci    Column() {
265e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ci    Column() {
268e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci    Column() {
271e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
272e41f4b71Sopenharmony_ci  }.width('100%').height(300).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.SpaceBetween)
273e41f4b71Sopenharmony_ci  ```
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci  ![en-us_image_0000001511900532](figures/en-us_image_0000001511900532.png)
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.SpaceAround)**: The elements are evenly distributed vertically. The space between any two adjacent elements is the same. The space between the first element and start edge, and that between the last element and end edge are both half the size of the space between two adjacent elements.
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci  ```ts
280e41f4b71Sopenharmony_ci  Column({}) {
281e41f4b71Sopenharmony_ci    Column() {
282e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci    Column() {
285e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci    Column() {
288e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
289e41f4b71Sopenharmony_ci  }.width('100%').height(300).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.SpaceAround)
290e41f4b71Sopenharmony_ci  ```
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci  ![en-us_image_0000001562700525](figures/en-us_image_0000001562700525.png)
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.SpaceEvenly)**: The elements are evenly distributed vertically. The space between the first element and start edge, the space between the last element and end edge, and the space between any two adjacent elements are the same.
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci  ```ts
297e41f4b71Sopenharmony_ci  Column({}) {
298e41f4b71Sopenharmony_ci    Column() {
299e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci    Column() {
302e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xD2B48C)
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci    Column() {
305e41f4b71Sopenharmony_ci    }.width('80%').height(50).backgroundColor(0xF5DEB3)
306e41f4b71Sopenharmony_ci  }.width('100%').height(300).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.SpaceEvenly)
307e41f4b71Sopenharmony_ci  ```
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci  ![en-us_image_0000001563060785](figures/en-us_image_0000001563060785.png)
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci### Horizontal Alignment of Child Elements in Row Container
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci  **Figure 8** Horizontal alignment of child elements in the Row container 
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci![vertial-arrangement-child-row](figures/vertial-arrangement-child-row.png)
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.Start)**: The items are horizontally aligned with each other toward the start edge of the container.
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci  ```ts
321e41f4b71Sopenharmony_ci  Row({}) {
322e41f4b71Sopenharmony_ci    Column() {
323e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci    Column() {
326e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci    Column() {
329e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
330e41f4b71Sopenharmony_ci  }.width('100%').height(200).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.Start)
331e41f4b71Sopenharmony_ci  ```
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci  ![en-us_image_0000001511421356](figures/en-us_image_0000001511421356.png)
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.Center)**: The elements are horizontally aligned with each other toward the center of the container. The space between the first component and the start edge is the same as that between the last component and the end edge.
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci  ```ts
338e41f4b71Sopenharmony_ci  Row({}) {
339e41f4b71Sopenharmony_ci    Column() {
340e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
341e41f4b71Sopenharmony_ci
342e41f4b71Sopenharmony_ci    Column() {
343e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci    Column() {
346e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
347e41f4b71Sopenharmony_ci  }.width('100%').height(200).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.Center)
348e41f4b71Sopenharmony_ci  ```
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci  ![en-us_image_0000001511900516](figures/en-us_image_0000001511900516.png)
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.End)**: The elements are horizontally aligned with each other toward the end edge of the container.
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci  ```ts
355e41f4b71Sopenharmony_ci  Row({}) {
356e41f4b71Sopenharmony_ci    Column() {
357e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci    Column() {
360e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci    Column() {
363e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
364e41f4b71Sopenharmony_ci  }.width('100%').height(200).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.End)
365e41f4b71Sopenharmony_ci  ```
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci  ![en-us_image_0000001562940601](figures/en-us_image_0000001562940601.png)
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.SpaceBetween)**: The elements are evenly distributed horizontally. The space between any two adjacent elements is the same. The first element is aligned with the start edge, the last element is aligned with the end edge, and the remaining elements are distributed so that the space between any two adjacent elements is the same.
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci  ```ts
372e41f4b71Sopenharmony_ci  Row({}) {
373e41f4b71Sopenharmony_ci    Column() {
374e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci    Column() {
377e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci    Column() {
380e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
381e41f4b71Sopenharmony_ci  }.width('100%').height(200).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.SpaceBetween)
382e41f4b71Sopenharmony_ci  ```
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci  ![en-us_image_0000001562700521](figures/en-us_image_0000001562700521.png)
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.SpaceAround)**: The elements are evenly distributed horizontally. The space between any two adjacent elements is the same. The space between the first element and start edge, and that between the last element and end edge are both half the size of the space between two adjacent elements.
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci  ```ts
389e41f4b71Sopenharmony_ci  Row({}) {
390e41f4b71Sopenharmony_ci    Column() {
391e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci    Column() {
394e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci    Column() {
397e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
398e41f4b71Sopenharmony_ci  }.width('100%').height(200).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.SpaceAround)
399e41f4b71Sopenharmony_ci  ```
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci  ![en-us_image_0000001562820893](figures/en-us_image_0000001562820893.png)
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci- **justifyContent(FlexAlign.SpaceEvenly)**: The elements are evenly distributed horizontally. The space between the first element and start edge, the space between the last element and end edge, and the space between any two adjacent elements are the same.
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci  ```ts
406e41f4b71Sopenharmony_ci  Row({}) {
407e41f4b71Sopenharmony_ci    Column() {
408e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci    Column() {
411e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xD2B48C)
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci    Column() {
414e41f4b71Sopenharmony_ci    }.width('20%').height(30).backgroundColor(0xF5DEB3)
415e41f4b71Sopenharmony_ci  }.width('100%').height(200).backgroundColor('rgb(242,242,242)').justifyContent(FlexAlign.SpaceEvenly)
416e41f4b71Sopenharmony_ci  ```
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci  ![en-us_image_0000001511421352](figures/en-us_image_0000001511421352.png)
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci## Adaptive Stretching
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ciIn linear layout, adaptive stretching is achieved by using the [Blank](../reference/apis-arkui/arkui-ts/ts-basic-components-blank.md) component, which automatically fills the empty spaces in the container – **Row** or **Column** – along the main axis. Just add the width and height as a percentage, and then adaptive scaling will take effect once the screen width and height change.
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci```ts
427e41f4b71Sopenharmony_ci@Entry
428e41f4b71Sopenharmony_ci@Component
429e41f4b71Sopenharmony_cistruct BlankExample {
430e41f4b71Sopenharmony_ci  build() {
431e41f4b71Sopenharmony_ci    Column() {
432e41f4b71Sopenharmony_ci      Row() {
433e41f4b71Sopenharmony_ci        Text('Bluetooth').fontSize(18)
434e41f4b71Sopenharmony_ci        Blank()
435e41f4b71Sopenharmony_ci        Toggle({ type: ToggleType.Switch, isOn: true })
436e41f4b71Sopenharmony_ci      }.backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }).width('100%')
437e41f4b71Sopenharmony_ci    }.backgroundColor(0xEFEFEF).padding(20).width('100%')
438e41f4b71Sopenharmony_ci  }
439e41f4b71Sopenharmony_ci}
440e41f4b71Sopenharmony_ci```
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci  **Figure 9** Portrait mode 
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci![en-us_image_0000001562820881](figures/en-us_image_0000001562820881.png)
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci  **Figure 10** Landscape mode 
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ci![en-us_image_0000001511421332](figures/en-us_image_0000001511421332.png)
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci## Adaptive Scaling
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ciAdaptive scaling means that the size of a child element is automatically adjusted according to a preset ratio to fit into the container across devices of various screen sizes. In linear layout, adaptive scaling can be achieved using either of the following methods:
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci- When the container size is determined, use **layoutWeight** to set the weight of a child element during layout. The container space is then allocated along the main axis among the element and sibling elements based on the set layout weight, ignoring the size settings of the elements themselves.
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci  ```ts
459e41f4b71Sopenharmony_ci  @Entry
460e41f4b71Sopenharmony_ci  @Component
461e41f4b71Sopenharmony_ci  struct layoutWeightExample {
462e41f4b71Sopenharmony_ci    build() {
463e41f4b71Sopenharmony_ci      Column() {
464e41f4b71Sopenharmony_ci        Text('1:2:3').width('100%')
465e41f4b71Sopenharmony_ci        Row() {
466e41f4b71Sopenharmony_ci          Column() {
467e41f4b71Sopenharmony_ci            Text('layoutWeight(1)')
468e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
469e41f4b71Sopenharmony_ci          }.layoutWeight(1).backgroundColor(0xF5DEB3).height('100%')
470e41f4b71Sopenharmony_ci
471e41f4b71Sopenharmony_ci          Column() {
472e41f4b71Sopenharmony_ci            Text('layoutWeight(2)')
473e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
474e41f4b71Sopenharmony_ci          }.layoutWeight(2).backgroundColor(0xD2B48C).height('100%')
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci          Column() {
477e41f4b71Sopenharmony_ci            Text('layoutWeight(3)')
478e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
479e41f4b71Sopenharmony_ci          }.layoutWeight(3).backgroundColor(0xF5DEB3).height('100%')
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci        }.backgroundColor(0xffd306).height('30%')
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ci        Text('2:5:3').width('100%')
484e41f4b71Sopenharmony_ci        Row() {
485e41f4b71Sopenharmony_ci          Column() {
486e41f4b71Sopenharmony_ci            Text('layoutWeight(2)')
487e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
488e41f4b71Sopenharmony_ci          }.layoutWeight(2).backgroundColor(0xF5DEB3).height('100%')
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci          Column() {
491e41f4b71Sopenharmony_ci            Text('layoutWeight(5)')
492e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
493e41f4b71Sopenharmony_ci          }.layoutWeight(5).backgroundColor(0xD2B48C).height('100%')
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci          Column() {
496e41f4b71Sopenharmony_ci            Text('layoutWeight(3)')
497e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
498e41f4b71Sopenharmony_ci          }.layoutWeight(3).backgroundColor(0xF5DEB3).height('100%')
499e41f4b71Sopenharmony_ci        }.backgroundColor(0xffd306).height('30%')
500e41f4b71Sopenharmony_ci      }
501e41f4b71Sopenharmony_ci    }
502e41f4b71Sopenharmony_ci  }
503e41f4b71Sopenharmony_ci  ```
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ci    **Figure 11** Landscape mode 
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_ci  ![en-us_image_0000001511421336](figures/en-us_image_0000001511421336.png)
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ci    **Figure 12** Portrait mode 
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_ci  ![en-us_image_0000001511580968](figures/en-us_image_0000001511580968.png)
512e41f4b71Sopenharmony_ci
513e41f4b71Sopenharmony_ci- When the container size is determined, set the width of a child element in percentage. The container space is then allocated among the element and sibling elements based on the set percentage.
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci  ```ts
516e41f4b71Sopenharmony_ci  @Entry
517e41f4b71Sopenharmony_ci  @Component
518e41f4b71Sopenharmony_ci  struct WidthExample {
519e41f4b71Sopenharmony_ci    build() {
520e41f4b71Sopenharmony_ci      Column() {
521e41f4b71Sopenharmony_ci        Row() {
522e41f4b71Sopenharmony_ci          Column() {
523e41f4b71Sopenharmony_ci            Text('left width 20%')
524e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
525e41f4b71Sopenharmony_ci          }.width('20%').backgroundColor(0xF5DEB3).height('100%')
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci          Column() {
528e41f4b71Sopenharmony_ci            Text('center width 50%')
529e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
530e41f4b71Sopenharmony_ci          }.width('50%').backgroundColor(0xD2B48C).height('100%')
531e41f4b71Sopenharmony_ci
532e41f4b71Sopenharmony_ci          Column() {
533e41f4b71Sopenharmony_ci            Text('right width 30%')
534e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
535e41f4b71Sopenharmony_ci          }.width('30%').backgroundColor(0xF5DEB3).height('100%')
536e41f4b71Sopenharmony_ci        }.backgroundColor(0xffd306).height('30%')
537e41f4b71Sopenharmony_ci      }
538e41f4b71Sopenharmony_ci    }
539e41f4b71Sopenharmony_ci  }
540e41f4b71Sopenharmony_ci  ```
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci    **Figure 13** Landscape mode 
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci  ![en-us_image_0000001563060777](figures/en-us_image_0000001563060777.png)
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci    **Figure 14** Portrait mode 
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_ci  ![en-us_image_0000001511740564](figures/en-us_image_0000001511740564.png)
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci## Adaptive Extension
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ciAdaptive extension allows users to drag the scrollbar to display the page content outside the screen. It is applicable to the scenario where the content extends beyond the viewport in linear layout. Below are the methods to implement adaptive extension in linear layout:
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci- [Add a scrollbar to a List component](arkts-layout-development-create-list.md#adding-a-scrollbar): If the list items cannot be fully displayed on one screen, you can place the child elements in different components and employ a scrollbar to display them. Use the **scrollBar** attribute to set the scrollbar status and the **edgeEffect** attribute to set the rebound effect when the scrollbar has reached the edge.
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci- Use a **Scroll** component: When one screen is not able to accommodate the full content, you can wrap a **Scroll** component at the outer layer of the **Column** or **Row** component to implement a scrollable linear layout.
558e41f4b71Sopenharmony_ci    Example of using a **Scroll** component in the vertical layout:
559e41f4b71Sopenharmony_ci
560e41f4b71Sopenharmony_ci  ```ts
561e41f4b71Sopenharmony_ci  @Entry
562e41f4b71Sopenharmony_ci  @Component
563e41f4b71Sopenharmony_ci  struct ScrollExample {
564e41f4b71Sopenharmony_ci    scroller: Scroller = new Scroller();
565e41f4b71Sopenharmony_ci    private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
566e41f4b71Sopenharmony_ci  
567e41f4b71Sopenharmony_ci    build() {
568e41f4b71Sopenharmony_ci      Scroll(this.scroller) {
569e41f4b71Sopenharmony_ci        Column() {
570e41f4b71Sopenharmony_ci          ForEach(this.arr, (item?:number|undefined) => {
571e41f4b71Sopenharmony_ci            if(item){
572e41f4b71Sopenharmony_ci              Text(item.toString())
573e41f4b71Sopenharmony_ci              .width('90%')
574e41f4b71Sopenharmony_ci              .height(150)
575e41f4b71Sopenharmony_ci              .backgroundColor(0xFFFFFF)
576e41f4b71Sopenharmony_ci              .borderRadius(15)
577e41f4b71Sopenharmony_ci              .fontSize(16)
578e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
579e41f4b71Sopenharmony_ci              .margin({ top: 10 })
580e41f4b71Sopenharmony_ci            }
581e41f4b71Sopenharmony_ci          }, (item:number) => item.toString())
582e41f4b71Sopenharmony_ci        }.width('100%')
583e41f4b71Sopenharmony_ci      }
584e41f4b71Sopenharmony_ci      .backgroundColor(0xDCDCDC)
585e41f4b71Sopenharmony_ci      .scrollable(ScrollDirection.Vertical) // Vertical scrolling.
586e41f4b71Sopenharmony_ci      .scrollBar(BarState.On) // The scrollbar is always displayed.
587e41f4b71Sopenharmony_ci      .scrollBarColor(Color.Gray) // The scrollbar color is gray.
588e41f4b71Sopenharmony_ci      .scrollBarWidth(10) // The scrollbar width is 10.
589e41f4b71Sopenharmony_ci      .edgeEffect(EdgeEffect.Spring) // The spring effect is produced when the scrollbar has reached the edge.
590e41f4b71Sopenharmony_ci    }
591e41f4b71Sopenharmony_ci  }
592e41f4b71Sopenharmony_ci  ```
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_ci  ![en-us_image_0000001511900524](figures/en-us_image_0000001511900524.gif)
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci  Example of using a **Scroll** component in the horizontal layout:
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci  ```ts
600e41f4b71Sopenharmony_ci  @Entry
601e41f4b71Sopenharmony_ci  @Component
602e41f4b71Sopenharmony_ci  struct ScrollExample {
603e41f4b71Sopenharmony_ci    scroller: Scroller = new Scroller();
604e41f4b71Sopenharmony_ci    private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
605e41f4b71Sopenharmony_ci  
606e41f4b71Sopenharmony_ci    build() {
607e41f4b71Sopenharmony_ci      Scroll(this.scroller) {
608e41f4b71Sopenharmony_ci        Row() {
609e41f4b71Sopenharmony_ci          ForEach(this.arr, (item?:number|undefined) => {
610e41f4b71Sopenharmony_ci            if(item){
611e41f4b71Sopenharmony_ci              Text(item.toString())
612e41f4b71Sopenharmony_ci              .height('90%')
613e41f4b71Sopenharmony_ci              .width(150)
614e41f4b71Sopenharmony_ci              .backgroundColor(0xFFFFFF)
615e41f4b71Sopenharmony_ci              .borderRadius(15)
616e41f4b71Sopenharmony_ci              .fontSize(16)
617e41f4b71Sopenharmony_ci              .textAlign(TextAlign.Center)
618e41f4b71Sopenharmony_ci              .margin({ left: 10 })
619e41f4b71Sopenharmony_ci            }
620e41f4b71Sopenharmony_ci          })
621e41f4b71Sopenharmony_ci        }.height('100%')
622e41f4b71Sopenharmony_ci      }
623e41f4b71Sopenharmony_ci      .backgroundColor(0xDCDCDC)
624e41f4b71Sopenharmony_ci      .scrollable(ScrollDirection.Horizontal) // Horizontal scrolling.
625e41f4b71Sopenharmony_ci      .scrollBar(BarState.On) // The scrollbar is always displayed.
626e41f4b71Sopenharmony_ci      .scrollBarColor(Color.Gray) // The scrollbar color is gray.
627e41f4b71Sopenharmony_ci      .scrollBarWidth(10) // The scrollbar width is 10.
628e41f4b71Sopenharmony_ci      .edgeEffect(EdgeEffect.Spring) // The spring effect is produced when the scrollbar has reached the edge.
629e41f4b71Sopenharmony_ci    }
630e41f4b71Sopenharmony_ci  }
631e41f4b71Sopenharmony_ci  ```
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci  ![en-us_image_0000001562940609](figures/en-us_image_0000001562940609.gif)
634