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
It would seem tedious to implement such complex functions manually every time.
405
405
If you want to be able to automatically generate component functions, you can introduce and refer to the [hikage-compiler](../library/hikage-compiler.md) module.
406
406
407
+
### Combination and Disassembly Layout
408
+
409
+
When building a UI, we usually use reusable layouts as components.
410
+
411
+
If you don't want each part to be customized separately using a native custom `View`, you can split the layout logic parts directly.
412
+
413
+
Hikage supports splitting layouts into multiple parts and combining them, you can use the `Hikageable` function anywhere to create a new `Hikage.Delegate` object.
414
+
415
+
> The following example
416
+
417
+
```kotlin
418
+
// Assume this is your main layout.
419
+
val mainLayout =Hikageable {
420
+
LinearLayout(
421
+
lparams =LayoutParams(matchParent =true),
422
+
init= {
423
+
orientation =LinearLayout.VERTICAL
424
+
}
425
+
) {
426
+
TextView {
427
+
text ="Hello, World!"
428
+
}
429
+
// Combination sublayout.
430
+
Layout(subLayout)
431
+
}
432
+
}
433
+
// Assume this is your layout submodule.
434
+
// Since the upper layout uses LinearLayout,
435
+
// you can declare LinearLayout.LayoutParams for the sublayout.
436
+
val subLayout =Hikageable<LinearLayout.LayoutParams> {
437
+
TextView(
438
+
lparams =LayoutParams {
439
+
topMargin =16.dp
440
+
}
441
+
) {
442
+
text ="Hello, Sub World!"
443
+
}
444
+
}
445
+
```
446
+
407
447
### Custom Layout Factory
408
448
409
449
Hikage supports custom layout factories and is compatible with `LayoutInflater.Factory2`.
0 commit comments