android – TextView多线

我有一个TextView,其中填充了从数据库中获取的文本,因此它的lenth是未定义的.

我已经使用maxline属性配置了TextView,并且我将其值设置为3,因为我不想要超过3行文本,而且我还使用了ellipsize属性.

但它不能正常工作.虽然文本大于3行,但它只打印两行.

<TextView
    android:id="@+id/etLugar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/tvLugar"        
    android:layout_marginLeft="15dp"
    android:layout_toRightOf="@+id/tvLugar"
    android:text="A very large text than must be shown in the textview, but no more of three lines are going to be shown"
    android:textColor="@color/foreground1"        
    android:maxLines="3"
    android:ellipsize="end"        
    android:textSize="12dp" 
    />

我不明白为什么maxlines属性不能正常工作.我做错了什么?

谢谢

最佳答案 我猜这是由于android:singleLine =“false”这是默认值try并将其更改为TRUE

告诉它是否有效.

点赞