HarmonyOS RelativeContainer无法根据子组件的高度,自适配自己的高度?

RelativeContainer无法根据子组件的高度,自适配自己的高度,详细代码

@Entry
@Component
export struct RelativeContainerDemo {
  build() {
    Column() {

      RelativeContainer() {

        Column() {
          Text('13241234')
            .fontColor('#333')

          Text('234234234')
            .fontColor('#333')
        }
        .alignRules({
          left: {anchor: "__container__", align: HorizontalAlign.Start},
          top: {anchor: "__container__", align: VerticalAlign.Top}
        })
        .id("Column2")

      }
      .width("auto").height("auto")
      .backgroundColor(Color.Red)

      Row().width('100%').height(40).backgroundColor(Color.Yellow)
    }
    .backgroundColor(Color.White)
    .width('100%').height('100%')
  }
}
阅读 450
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进