当前位置:   article > 正文

HarmonyOS Text超出部分末尾显示..._harmonyos 文字超出缩略

harmonyos 文字超出缩略

HarmonyOS Text 默认是显示一行,想要Text超出部分末尾显示...

设置 truncation_mode="ellipsis_at_end" 即可,

truncation_mode 还有其他的属性, 当truncation_mode="ellipsis_at_start" 设置为true是点点在文字开头显示,当 truncation_mode="ellipsis_at_middle" 在中间的时候点点在中间显示.

xml 代码如下

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <DirectionalLayout
  3. xmlns:ohos="http://schemas.huawei.com/res/ohos"
  4. ohos:height="match_parent"
  5. ohos:width="match_parent"
  6. ohos:orientation="vertical">
  7. <Text
  8. ohos:id="$+id:text"
  9. ohos:height="match_content"
  10. ohos:width="200vp"
  11. ohos:text="窗前明月光,疑是地上霜."
  12. ohos:text_size="22fp"
  13. ohos:truncation_mode="ellipsis_at_end"
  14. ohos:top_margin="50vp"/>
  15. <Text
  16. ohos:id="$+id:text1"
  17. ohos:height="match_content"
  18. ohos:width="200vp"
  19. ohos:text="窗前明月光,疑是地上霜."
  20. ohos:text_size="22fp"
  21. ohos:truncation_mode="ellipsis_at_start"
  22. ohos:top_margin="50vp"/>
  23. <Text
  24. ohos:id="$+id:text2"
  25. ohos:height="match_content"
  26. ohos:width="200vp"
  27. ohos:text="窗前明月光,疑是地上霜."
  28. ohos:text_size="22fp"
  29. ohos:truncation_mode="ellipsis_at_middle"
  30. ohos:top_margin="50vp"/>
  31. </DirectionalLayout>

效果图:

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/281119
推荐阅读
相关标签
  

闽ICP备14008679号