对应paint的breakText方法实现

对应paint的breakText方法实现

HarmonyOS
2024-05-06 22:39:29
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
LenZhong
import measure from ‘@ohos.measure’ 
 
@Entry 
@Component 
struct Index { 
@State message: string = ‘xxxxxxxxxxxxxxxxaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb’; 
textSize: SizeOptions = measure.measureTextSize({ 
textContent: this.message, 
fontSize: ‘50px’, 
constraintWidth: 50 
}) 
 
build() { 
Row() { 
Column() { 
Text(this.message) 
.width(this.textSize.width) 
.maxLines(1) 
.textOverflow({ overflow: TextOverflow.Ellipsis }) 
.onClick(() => { 
console.log(“textSize====height:” + this.textSize.height); 
}) 
} 
.width(‘100%’) 
} 
.height(‘100%’) 
} 
}
分享
微博
QQ
微信
回复
2024-05-07 15:30:36
相关问题
同意取消弹窗怎么实现?用哪个方法
3750浏览 • 1回复 待解决
Binder链接池实现有哪些方法
410浏览 • 1回复 待解决
原子布局能力对应api
8238浏览 • 1回复 待解决
VectorElement怎么定义对应xml
7648浏览 • 2回复 待解决
安卓Transformation对应鸿蒙哪个类?
3228浏览 • 1回复 待解决
弧形进度条实现,有人知道方法吗?
373浏览 • 1回复 待解决
鸿蒙有没有clipToPadding所对应属性
3764浏览 • 1回复 待解决