WordBreak.BREAK_WORD与WordBreak.BREAK_ALL的区别是什么?

WordBreak.BREAK_WORD与WordBreak.BREAK_ALL的区别是什么?

https://ost.51ct
2024-08-05 16:46:17
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
truemichael

BREAK_ALL可在任意2个字符间断行,BREAK_WORD优先按破发点(如空白符)换行,若整一行文本均无断行破发点时,则在任意2个字符间断行.

举例说明:

@State text: string =
  'The text component is used to display a piece of textual information.Support universal attributes and universal text attributes.'
build() {
  Column() {
    Text(this.text)
      .fontSize(12)
      .border({ width: 1 })
      .maxLines(2)
      .textOverflow({ overflow: TextOverflow.Ellipsis })
      .wordBreak(WordBreak.BREAK_ALL)//WordBreak.BREAK_WORD
      .lineHeight(20)
      .width(260)

  }.width("100%")
  .height("100%")
  .justifyContent(FlexAlign.Center)
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.

BREAK_WORD:

BREAK_ALL:

分享
微博
QQ
微信
回复
2024-08-05 22:01:16
相关问题
EmitterEventHub区别是什么
1859浏览 • 2回复 待解决
请问PreviewerSimulator区别是什么
1200浏览 • 1回复 待解决
FA模型Stage模型区别是什么
1632浏览 • 1回复 待解决
HTTP原生库RCP区别是什么
1217浏览 • 1回复 待解决
HAP和HAR区别是什么
3031浏览 • 1回复 待解决
sync和await区别是什么?
1367浏览 • 1回复 待解决
navigation和router区别是什么
2427浏览 • 1回复 待解决
@State和@Link区别是什么
287浏览 • 0回复 待解决
多态和多模区别是什么
6905浏览 • 2回复 已解决