HarmonyOS【ArkUI组件--Text】

1.Text文本显示组件

2.编写代码

在上一篇博客的基础上继续

HarmonyOS【ArkUI组件---Image组件】-CSDN博客

①新建ImagePage.ets

② 设置文本串

(1)base中的string.json

javascript 复制代码
 {
      "name": "width_label",
      "value": "Image Width:"
    }

(2) en_US中的string.json

javascript 复制代码
 {
      "name": "width_label",
      "value": "Image Width:"
    }

(3)zh_CN中的string.json

javascript 复制代码
{
      "name": "width_label",
      "value": "图片宽度:"
    }

③ImagePage 代码

javascript 复制代码
import font from '@ohos.font'
@Entry
@Component
struct Index {
  @State message: string = 'Hello World'

  build() {
    Row() {
      Column() {

        Image($r('app.media.app_icon'))
          .width(250)
          .interpolation(ImageInterpolation.High)
        Text($r('app.string.width_label'))
          .fontSize(20)
          .fontWeight(FontWeight.Bold)
      }

      .width('100%')
    }
    .height('100%')
  }
}

④效果如下

相关推荐
zhanshuo8 小时前
在鸿蒙里优雅地处理网络错误:从 Demo 到实战案例
harmonyos
zhanshuo9 小时前
在鸿蒙中实现深色/浅色模式切换:从原理到可运行 Demo
harmonyos
whysqwhw14 小时前
鸿蒙分布式投屏
harmonyos
whysqwhw15 小时前
鸿蒙AVSession Kit
harmonyos
whysqwhw17 小时前
鸿蒙各种生命周期
harmonyos
whysqwhw18 小时前
鸿蒙音频编码
harmonyos
whysqwhw18 小时前
鸿蒙音频解码
harmonyos
whysqwhw18 小时前
鸿蒙视频解码
harmonyos
whysqwhw18 小时前
鸿蒙视频编码
harmonyos
ajassi200018 小时前
开源 Arkts 鸿蒙应用 开发(十八)通讯--Ble低功耗蓝牙服务器
华为·开源·harmonyos