HarmonyOS Text组件的布局跟随效果怎么实现?

阅读 568
1 个回答

可以参考如下demo:

@Entry
@Component
struct Index {
  build() {
    Row() {
      Column() {
        Flex({ justifyContent:FlexAlign.Start, alignItems: ItemAlign.Center}){
          Text('文本标题文本标题文本标题文本标题文本标题文本标题')
            .fontColor('#000000')
            .fontSize(14)
            .textAlign(TextAlign.Start)
            .margin({left:8})
            .textOverflow({ overflow: TextOverflow.Ellipsis })
            .maxLines(1)
          Image($r('app.media.ic_ok')).width(50).height(50)
        }
      }.backgroundColor(Color.Yellow)
      .width('100%')
      .height('20%')
    }
    .width('100%')
  }
}