RelativeContainer() {
Line()
.width("100%")
.height(20)
.margin({ top: 100 })
.backgroundColor("#ff0000")
.alignRules({
top: {
anchor: "__container__", align: VerticalAlign.Top,
},
})
.id("a1")
Text("我是中间测试")
.width("100%")
.backgroundColor("#00ff00")
.alignRules({
top: {
anchor: "a1", align: VerticalAlign.Bottom,
}, bottom: {
anchor: "a2", align: VerticalAlign.Top,
},
})
Line()
.width("100%")
.height(20)
.margin({ bottom: 100 })
.backgroundColor("#ff0000")
.alignRules({
bottom: {
anchor: "__container__", align: VerticalAlign.Bottom,
},
})
.id("a2")
}
.height('100%')
.width('100%').backgroundColor(Color.White)

image.png
// 设置固定height(100) 在a1 和a2中间

image.png
//设置height("auto") 自动适应大小居中

image.png
//height("100%")全屏大小

image.png
//不设置 height 在a1 和a2中间充满