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%')
  }
}

④效果如下

相关推荐
遇到困难睡大觉哈哈1 小时前
Harmony os——ArkTS 语言笔记(六):模块、导入导出与 `this` 关键字
笔记·harmonyos·鸿蒙
Brianna Home1 小时前
[鸿蒙2025领航者闯关] 鸿蒙 6.0 星盾安全架构 + AI 防窥:金融级支付安全实战与深度踩坑实录
人工智能·安全·harmonyos·安全架构
bestadc3 小时前
鸿蒙应用开发的MVVM(Model-View-ViewModel)模式
华为·harmonyos
HONG````4 小时前
鸿蒙Tabs组件深度实战:构建流畅的多页面导航与状态保持方案
华为·harmonyos
ZWaruler4 小时前
鸿蒙os 配置打包后的文件名称
华为·harmonyos·鸿蒙系统
Devil枫4 小时前
[鸿蒙2025领航者闯关]从小白到鸿蒙星炬手
华为·harmonyos
遇到困难睡大觉哈哈5 小时前
Harmony os ——ArkTS 语言笔记(五):泛型、空安全与可选链
前端·笔记·安全·harmonyos·鸿蒙
财经三剑客7 小时前
鸿蒙智行全系11月交付81864台 同比增长89.61%
华为·harmonyos
7 小时前
鸿蒙——首选项
华为·harmonyos
hqk8 小时前
鸿蒙 ArkUI 从零到精通:基础语法全解析
android·前端·harmonyos