You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/guide/advanced/the-layout-process.md
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,15 @@
1
1
---
2
2
title: The Layout Process
3
+
description: For all views to render with the right dimensions and positions requires a run of the layout process.
4
+
contributors:
5
+
- Ombuweb
6
+
- NathanWalker
7
+
- rigor789
3
8
---
4
9
5
-
The ability for all your views to render with the right dimensions and positions requires a run of "the layout process". When rendering, a recursive process runs through every view in the **view hierarchy** in two passes — a measure pass and a layout pass.
10
+
When rendering, a recursive process runs through every view in the **view hierarchy** in two passes — a measure pass and a layout pass.
6
11
7
-
During **the measure pass** every view is measured to obtain its desired size. The following properties are considered during the measuring:
12
+
During **the measure pass** every view is measured to obtain its desired size. The following properties are considered during measuring:
8
13
9
14
-`width`, `height`
10
15
-`minWidth`, `minHeight`
@@ -17,14 +22,13 @@ During **the layout pass** every view is placed in a specific layout slot. The s
17
22
-`horizontalAlignment`, `verticalAlignment`
18
23
19
24
The layout process is by nature an resource-intensive process and it's performance highly depends on the number views (and complexity).
20
-
<!-- TODO: fix links -->
25
+
21
26
:::tip
27
+
22
28
It's a good practice to minimize deep nesting of views. Instead, utilize different [Layout Containers](/ui/#layout-containers) to achieve a simpler and more organized view hierarchy. This approach improves readability, maintainability and performance.
23
29
24
30
**For example:** don't treat `<StackLayout>` as a `<div>`— instead try to use a `<GridLayout>` with specific `rows` and `columns` to achieve the same result:
25
31
26
-
- Bad Practice:
27
-
28
32
```html
29
33
<StackLayout>
30
34
<StackLayoutorientation="horizontal">
@@ -37,7 +41,8 @@ It's a good practice to minimize deep nesting of views. Instead, utilize differe
37
41
</StackLayout>
38
42
```
39
43
40
-
- Good Practice:
44
+
Better version:
45
+
41
46
<!---->
42
47
43
48
```html
@@ -50,4 +55,4 @@ It's a good practice to minimize deep nesting of views. Instead, utilize differe
50
55
51
56
One-offs are fine with the `<StackLayout>` approach, but building an entire app with the first approach will usually result in poor performance.
0 commit comments