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

查看:20
本文介绍了带有多行和“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 及更高版本上的多行.您可以尝试以下方法,但您只有一行.将以下内容添加到您的文本视图中.

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天全站免登陆