参考demo:@Entry @Component struct Index { build() { Row() { RelativeContainer() { Row().width(100).height(100) .backgroundColor("#FF3333") .alignRules({ top: {anchor: "__container__", align: VerticalAlign.Top}, bottom : {anchor : "__container__", align : VerticalAlign.Bottom}, left: {anchor: "__container__", align: HorizontalAlign.Start}, right : {anchor : "__container__", align: HorizontalAlign.End}, bias : {vertical : 0.3} }) .id("row1") } .width(300).height(300) .margin({left: 50}) .border({width:2, color: "#6699FF"}) } .height('100%') } }
参考demo: