【问题标题】:ellipsize=end is replacing the entire last line with an ellipsis [duplicate]ellipsize=end 用省略号替换整个最后一行[重复]
【发布时间】:2018-06-06 00:47:52
【问题描述】:

这是我的 TextView 的 XML 元素:

<TextView
    android:id="@+id/todo_notes"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="end"
    android:maxLines="3"
    android:textAppearance="@style/TextAppearance.AppCompat.Body1"
    tools:text="This is a long description of what has to be done to make this task complete. It might only be one or two words (if the title is specific enough), or it might be a whole lot more than that." />

它包含在一个垂直的 LinearLayout 中(您可能可以从屏幕截图中猜到)。

看起来是这样的:

这就是我想要的样子:

简而言之,我希望省略号位于最后一行的末尾,而不是替换最后一行。我怎样才能做到这一点?我更喜欢不需要任何 Java 的解决方案,但如果这不可能,我可以接受。

我在 Android Studio 3.0.1 上,使用 API 27 查看它。我可以通过将 &lt;TextView&gt; 复制并粘贴到空白文件(&lt;?xml&gt; 标题除外)文件中来重现此错误,具有足够窄的屏幕尺寸,文本可以换行超过三行。

【问题讨论】:

    标签: android android-studio textview ellipsis


    【解决方案1】:

    似乎以下主题回答了您的问题: Setting Ellipsize on TextView reduces lines shown by one (instead of only ellipsizing last) 一个答案表明这只是预览器的错误。

    【讨论】:

    • 看起来很有希望!你现在没有足够的代表,但是一旦你这样做了(对一个问题或答案再投票一次),你应该将像我这样的问题标记为重复。你会在标签下看到一个灰色的小链接,指向“flag”;点击它会弹出一个菜单。其中一个选项将是“重复”,您可以将 URL 放在那里。
    • 我只记得我可以关闭自己的问题,哈哈。哎呀。
    猜你喜欢
    • 2014-07-18
    • 2018-10-06
    • 2012-08-09
    • 1970-01-01
    • 2012-01-22
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    相关资源
    最近更新 更多