HarmonyOS 如何设置RichEditor字体居中

@Builder
supView(str?: string) {
  Text(str ? str : '')
    .fontSize(this.txtSize)
    .height(this.txtSize * 2)

}

this.controller.addTextSpan(item.content,
  {
    style:
    {
      fontColor: this.txtColor,
      fontSize: this.txtSize,
      fontWeight: this.fontWeight
    }
  })
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.

显示不上下居中,显示靠底部。能否设置字体上下居中?

HarmonyOS
2024-12-25 12:54:44
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

示例参考:

RichEditor({ controller: this.controllerRich })
  .width('100%')
  .height(40)
  .layoutWeight(1)
  .borderRadius(10)
  .backgroundColor(Color.Red)
  .margin({ top: 20, left: 14, bottom: 5 })
  .key('RichEditor')
  .id('id')
  .placeholder('平台提倡文明用语,请温柔发言哦~', { font: { size: 12 }, fontColor: '#999999' })
  .defaultFocus(true)
  .onReady(() => {
    this.controllerRich.addTextSpan("0123456789\n", {
      style: { fontColor: Color.Pink, fontSize: "32", },
      paragraphStyle: { textAlign: TextAlign.Center, leadingMargin: 16 }
    })
  }) 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.

参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-richeditor-V5#richeditorcontroller

分享
微博
QQ
微信
回复
2024-12-25 15:34:40


相关问题
RichEditor组件如何设置初始字体样式
1656浏览 • 1回复 待解决
HarmonyOS RichEditor 内容不居中显示
692浏览 • 1回复 待解决
HarmonyOS RichEditor设置controller
509浏览 • 1回复 待解决
HarmonyOS 如何设置全局字体
851浏览 • 1回复 待解决
HarmonyOS 字体大小如何设置
2192浏览 • 1回复 待解决
HarmonyOS 全局设置字体
548浏览 • 1回复 待解决
HarmonyOS 字体行高应该如何设置
567浏览 • 1回复 待解决
HarmonyOS Text设置align不居中
1165浏览 • 1回复 待解决
HarmonyOS Navigation标题居中,背景设置
1967浏览 • 1回复 待解决
HarmonyOS 如何设置状态字体颜色
709浏览 • 1回复 待解决
HarmonyOS 如何设置自定义字体
1623浏览 • 1回复 待解决
HarmonyOS RN字体设置demo
641浏览 • 1回复 待解决
鸿蒙IndexBar如何设置字体大小?
7590浏览 • 1回复 待解决
HarmonyOS webview字体大小设置
765浏览 • 1回复 待解决
HarmonyOS 全局设置字体没效果
539浏览 • 1回复 待解决
HarmonyOS RichEditor如何使用?
1066浏览 • 1回复 待解决
HarmonyOS 如何获取设置中系统字体大小
1267浏览 • 1回复 待解决
HarmonyOS TabContent怎么设置字体颜色
754浏览 • 1回复 待解决