HarmonyOS alignRules属性

RelativeContainer(){
  Text("七日年化")
    .fontSize(13)
    .alignRules({
      left: {
        anchor: "qrnh_color_view",
        align: HorizontalAlign.End
      }
    })
    .margin({
      left: 7
    })
    .fontColor("#797c8f")
    .id("tv_qrnh")

  Text("")
    .width(9)
    .height(4)
    .backgroundColor("#ff5736")
    .alignRules({
      top: {
        anchor: "tv_qrnh",
        align: VerticalAlign.Bottom
      }
    })
    .id("qrnh_color_view")

  // Text("1.20%")
  //   .fontColor("#ff5736")
  //   .fontSize(15)
  //   .alignRules({
  //     left: {
  //       anchor: 'qrnh_color_view',
  //       align: HorizontalAlign.Start
  //     }
  //   })
  //   .id('tv_qrnh_value')
}
.id("left")
.width("200")
.height("100")
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.

我去掉qrnh_color_view的alignRules属性就显示,加上就不显示 是为啥

HarmonyOS
2024-12-24 15:29:45
325浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

可以使用容器组件把text包裹起来,就可以正常展示了

@Entry
@Component
struct Index {

  build() {
    RelativeContainer() {

      Row() {
        Text("七日年化")
          .fontSize(13)
          .margin({
            left: 7
          })
          .fontColor("#797c8f")
          .id("tv_qrnh")
      }.alignRules({
        left: {
          anchor: "qrnh_color_view",
          align: HorizontalAlign.End
        }
      })

      Row() {
        Text("2")
          .width(9)
          .height(4)
          .backgroundColor("#ff5736")
          .id("qrnh_color_view")
      }.alignRules({
        top: {
          anchor: "tv_qrnh",
          align: VerticalAlign.Bottom
        }
      })


      // Text("1.20%")
      // .fontColor("#ff5736")
      // .fontSize(15)
      // .alignRules({
      // left: {
      // anchor: 'qrnh_color_view',
      // align: HorizontalAlign.Start
      // }
      // })
      // .id('tv_qrnh_value')

    }
    .id("left")
    .width("200")
    .height("100")
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
分享
微博
QQ
微信
回复
2024-12-24 18:11:05


相关问题
HarmonyOS Hyperlink属性
1074浏览 • 0回复 待解决
HarmonyOS RichText属性使用
793浏览 • 1回复 待解决
HarmonyOS relativeContainer设置guideLine属性
389浏览 • 1回复 待解决
HarmonyOS 属性字符如何设置
225浏览 • 1回复 待解决
HarmonyOS 如何遍历对象属性
461浏览 • 1回复 待解决
HarmonyOS Image组件着色属性
407浏览 • 1回复 待解决
HarmonyOS 组件设置属性无效果
885浏览 • 1回复 待解决
HarmonyOS 是否有提供倾斜属性
623浏览 • 1回复 待解决
HarmonyOS friction属性的替代接口
274浏览 • 1回复 待解决
customKeyboard属性使用问题
998浏览 • 1回复 待解决
HarmonyOS 通过属性来传递组件
352浏览 • 1回复 待解决
HarmonyOS 属性直通要怎么实现?
329浏览 • 1回复 待解决
HarmonyOS 属性动效如何打断
440浏览 • 1回复 待解决
HarmonyOS Span的属性设置失效
289浏览 • 1回复 待解决
HarmonyOS 组件.bindPopup属性使用问题
779浏览 • 1回复 待解决
HarmonyOS list中属性chainAnimation作用
286浏览 • 1回复 待解决
HarmonyOS文件创建时间属性用哪个
945浏览 • 1回复 待解决
HarmonyOS 属性动画中途如何停止?
802浏览 • 1回复 待解决
HarmonyOS endable对象属性napi无法修改
449浏览 • 1回复 待解决
HarmonyOS 字符串属性问题
370浏览 • 1回复 待解决
提问
该提问已有2人参与 ,帮助了10人
恭喜您,今日已阅读两篇内容,特奖励+2声望, 快来领取吧。