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")

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

HarmonyOS
2024-12-24 15:29:45
浏览
收藏 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")
  }
}
分享
微博
QQ
微信
回复
2024-12-24 18:11:05
相关问题
HarmonyOS Hyperlink属性
739浏览 • 0回复 待解决
HarmonyOS RichText属性使用
542浏览 • 1回复 待解决
HarmonyOS 属性字符如何设置
114浏览 • 1回复 待解决
HarmonyOS 如何遍历对象属性
136浏览 • 1回复 待解决
HarmonyOS relativeContainer设置guideLine属性
196浏览 • 1回复 待解决
HarmonyOS Image组件着色属性
171浏览 • 1回复 待解决
HarmonyOS friction属性的替代接口
154浏览 • 1回复 待解决
HarmonyOS 是否有提供倾斜属性
342浏览 • 1回复 待解决
HarmonyOS 组件设置属性无效果
686浏览 • 1回复 待解决
HarmonyOS 属性直通要怎么实现?
170浏览 • 1回复 待解决
HarmonyOS 属性动效如何打断
190浏览 • 1回复 待解决
HarmonyOS Span的属性设置失效
138浏览 • 1回复 待解决
HarmonyOS list中属性chainAnimation作用
118浏览 • 1回复 待解决
HarmonyOS 组件.bindPopup属性使用问题
487浏览 • 1回复 待解决
HarmonyOS 通过属性来传递组件
239浏览 • 1回复 待解决
customKeyboard属性使用问题
884浏览 • 1回复 待解决
HarmonyOS 有没有类似clipChildren的属性
286浏览 • 1回复 待解决
HarmonyOS文件创建时间属性用哪个
636浏览 • 1回复 待解决
HarmonyOS 是否支持对象属性进行修改
137浏览 • 1回复 待解决
提问
该提问已有0人参与 ,帮助了0人