2
  • 我有TextView描述(从 1 行到 10+ 行)
  • 如果我将字体大小更改为,我希望文本清晰Settings -> Accessibility -> Font Size可见Largest
  • 我有一些空间,但不足以显示完整的描述
  • 我选择最多显示 6 行
  • 我想在描述的末尾省略号

TL;DR:如果文本太长,我希望行 < 6 并且末尾有省略号。这不会发生(下图)。如何使TextView行号调整为文本长度并始终在末尾添加省略号?

你如何处理这样的问题?也许我应该从不同的角度考虑?哪一个?或者我试着在吃蛋糕的同时吃蛋糕?

细节:

前面提到的TextView里面ConstaintLayout(这就是为什么android:layout_width/height="0dp"

 <TextView
        android:id="@+id/custom_list_item_description"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:ellipsize="end"
        android:maxLines="6"
        app:autoSizeMinTextSize="14sp"
        app:autoSizeTextType="uniform"
        <!-- some constraints -->
        tools:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." />

怎么了: 文本在 6 行处被修剪,这很难看。 而不是椭圆形。

然后我改成autoSizeMinTextSize"10sp",碰巧所有的描述都匹配成TextView很好的椭圆,但是对于有眼睛残疾的人来说字体太小了。

4

0 回答 0