对应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
相关问题
安卓Transformation对应鸿蒙哪个类?
2678浏览 • 1回复 待解决
同意取消弹窗怎么实现?用哪个方法
3185浏览 • 1回复 待解决
VectorElement怎么定义对应xml
7126浏览 • 2回复 待解决
原子布局能力对应api
7757浏览 • 1回复 待解决
如何通过资源ID拿到对应资源?
5557浏览 • 3回复 待解决
鸿蒙有没有clipToPadding所对应属性
3260浏览 • 1回复 待解决