HarmonyOS 鸿蒙Next Text 图文混排,怎么让图片和文字在同一排
HarmonyOS 鸿蒙Next Text 图文混排,怎么让图片和文字在同一排
Text(){
![zan_icon_select](app.media.zan_icon_select)
asdnkalsdkjashjklfhjkshjfklhaklshfjklhasjklfhjksldhfjkdshjklfhkdlshfkldshfkldshfklhsdkjlfhkjlsd
}
文字过长会自动排到下一行
4 回复
可以给Text()
组件设置wordBreak
属性,参考一下如下代码:
Text() {
ImageSpan($r("app.media.startIcon")).width(20).height(20)
Span("asdnkalsdkjashjklfhjkshjfklhaklshfjklhasjklfhjksldhfjkdshjklfhkdlshfkldshfkldshfklhsdkjlfhkjlsd")
}
.wordBreak(1)
更多关于HarmonyOS 鸿蒙Next Text 图文混排,怎么让图片和文字在同一排的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
如果想保持单词的完整性,最好使用BREAK_WORD这个属性
Text() {
ImageSpan($r("app.media.news_user_select")).width(20).height(20)
Span("The meaning of separation is to never see each other again")
}
.width('100%')
.wordBreak(WordBreak.BREAK_WORD)
wordBreak文档:
Text() {
ImageSpan($r("app.media.news_user_select")).width(20).height(20)
Span("sdnkalsdkjashjklfhjkshjfklhaklshfjklhasjklfhjksldhfjkdshjklfhkdlshfkldshfkldshfklhsdkjlfhkjlsd")
}
.width('100%')
.wordBreak(WordBreak.BREAK_ALL)