Layout done in code:
- Is type-safe, which is verified at compile-time.
- Will break at compile-time if a breaking change is made.
- Can be null-safe, without having to use Optional for everything.
- Can do things iteratively.
- Can use constants, so that you can easily modify standard paddings and sizes globally with one change.
So those are some of the advantages of doing layout in code.