可以参考此demo如下:@Entry @Component struct Index { build() { List() { ListItem() { RelativeContainer() { Row() .width(100) .height(100) .backgroundColor('#FF3333') .alignRules({}) .id('row1') Row() .width(100) .height(100) .backgroundColor('#FFCC00') .alignRules({ top: { anchor: 'row1', align: VerticalAlign.Top }, left: { anchor: 'row1', align: HorizontalAlign.End }, }) .id('row2') Row() .height(100) .width(100) .backgroundColor('#FF6633') .alignRules({ left: { anchor: 'row1', align: HorizontalAlign.Start }, top: { anchor: 'row1', align: VerticalAlign.Bottom } }) .id('row3') } .height('auto') .margin({ left: 50 }) .border({ width: 2, color: '#6699FF' }) } ListItem() { RelativeContainer() { Row() .width(100) .height(100) .backgroundColor('#FF3333') .alignRules({}) .id('row1') Row() .width(100) .height(100) .backgroundColor('#FFCC00') .alignRules({ top: { anchor: 'row1', align: VerticalAlign.Top }, left: { anchor: 'row1', align: HorizontalAlign.End }, }) .id('row2') Row() .height(100) .width(100) .backgroundColor('#FF6633') .alignRules({ left: { anchor: 'row1', align: HorizontalAlign.Start }, top: { anchor: 'row1', align: VerticalAlign.Bottom } }) .id('row3') } .height('auto') .margin({ left: 50 }) .border({ width: 2, color: '#6699FF' }) } ListItem() { RelativeContainer() { Row() .width(100) .height(100) .backgroundColor('#FF3333') .alignRules({}) .id('row1') Row() .width(100) .height(100) .backgroundColor('#FFCC00') .alignRules({ top: { anchor: 'row1', align: VerticalAlign.Top }, left: { anchor: 'row1', align: HorizontalAlign.End }, }) .id('row2') Row() .height(100) .width(100) .backgroundColor('#FF6633') .alignRules({ left: { anchor: 'row1', align: HorizontalAlign.Start }, top: { anchor: 'row1', align: VerticalAlign.Bottom } }) .id('row3') } .height('auto') .margin({ left: 50 }) .border({ width: 2, color: '#6699FF' }) } } .backgroundColor('#FFF1F3F5') .alignListItem(ListItemAlign.Center) } }
可以参考此demo如下: