具有多行和"android:ellipsize = middle"的Android TextView; [英] Android TextView with multiline and "android:ellipsize = middle"

查看:409
本文介绍了具有多行和"android:ellipsize = middle"的Android TextView;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<TextView
        android:id="@+id/food_item_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:gravity="bottom|center_horizontal"
        android:maxLines="2"
        android:ellipsize="middle"
        android:textSize="17sp"
        android:textColor="@color/food_cell_text"
        android:text=""Cured beef salad with rocket lettuce,cherry tomato & grana padano""/>

但是TextView中的文本中间没有省略号,就好像 属性不是没有用的,当我改变 android:ellipsize="end",文本末尾带有省略号.为什么?中间怎么有省略号?

But the text in the TextView do not have ellipsis in the middle as if the attributes is not useless,When I change android:ellipsize="end", The text have ellipsis in the end. Why? And how can I have ellipsis in the middle?

推荐答案

android:ellipsize="middle"在Android 4.0及更高版本上似乎不适用于多行.您可以尝试执行以下操作,但是只有一行.将以下内容添加到您的textview中.

android:ellipsize="middle" doesn't seem to work with multiple lines on Android 4.0 and later. you could try the following which will work, however you only have the one line. Add the following to your textview.

android:singleLine="true"

这篇关于具有多行和"android:ellipsize = middle"的Android TextView;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆