HarmonyOS row包裹的ab两个个子元素,如何让Row的高度自适应a的高度,让b的高度等于row的高度

Row(){
  a()
  b()
}

如果给b设置height('100%)那么Row就不能自适应a的高度,如何让b撑满Row?

HarmonyOS
2024-12-25 13:05:45
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Excelsior_abit

参考示例如下:

@Entry
@Component
struct Test {
  @State message: string = 'Hello World';
  @State bHeight: string = 'auto';

  build() {
    Row() {
      Text("a")
        .height(80)
        .backgroundColor(Color.Pink)
        .onAreaChange((oldValue: Area, newValue: Area) => {
          console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`)
          this.bHeight = JSON.stringify(newValue.height)
        })

      Text("b")
        .height(this.bHeight)
        .backgroundColor(Color.Yellow)
    }
    .height('auto')
    .backgroundColor(Color.Gray)
  }
}
分享
微博
QQ
微信
回复
2024-12-25 15:46:39
相关问题
HarmonyOS web高度自适应内容高度
305浏览 • 1回复 待解决
HarmonyOS 高度自适应问题
504浏览 • 1回复 待解决
HarmonyOS 如何实现自适应web高度
46浏览 • 1回复 待解决
HarmonyOS 高度自适应
420浏览 • 1回复 待解决
HarmonyOS RichText自适应高度
165浏览 • 1回复 待解决
HarmonyOS Web高度自适应问题
934浏览 • 1回复 待解决
HarmonyOS webview高度不能自适应
85浏览 • 1回复 待解决
HarmonyOS RelativeContainer无法自适应高度
579浏览 • 1回复 待解决
HarmonyOS RichText能否自适应高度
183浏览 • 1回复 待解决
HarmonyOS RelativeContainer自适应高度相关
203浏览 • 1回复 待解决
HarmonyOS GridItem自适应高度问题
552浏览 • 1回复 待解决
HarmonyOS Grid高度根据内容自适应
232浏览 • 1回复 待解决