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

阅读 566
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%')
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进