微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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 告诉它是否有效.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐