【问题标题】:Word has not enough space in single lineWord 在单行中没有足够的空间
【发布时间】:2017-01-01 19:07:56
【问题描述】:

我有一个字体大小很大的 TextView,如果我的单词很长,则只有最后一个字符被放入下一行。例如:

祖萨梅纳尔贝

t

现在我想将文本格式化为如下所示:

祖萨梅纳布-

t

有没有可能做到这一点?

【问题讨论】:

标签: android textview hyphenation


【解决方案1】:

我想比做断字更好,你可以做一些更好的事情。考虑下图。

我想绿色的会很适合你的需要。只需如下声明您的textview

 <TextView
            android:id="@+id/yourUniqueID"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp"
            android:ellipsize="end"  <!--THIS WILL DO FOR YOU-->
            android:maxLines="1"
            android:text="test"/>

【讨论】:

  • 您好,谢谢您的回答,但是 textview 有多行,这不是最后一行,所以我不能使用这个策略
  • 然后在一定程度上减小文本大小
【解决方案2】:

TextView的破发策略

android:breakStrategy="high_quality"

constant      value               description
high_quality    1   Line breaking uses high-quality strategy, including hyphenation.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-28
    相关资源
    最近更新 更多