我怎样才能显示我的TextView的省略号如果是大于1行? [英] How can I show ellipses on my TextView if it is greater than the 1 line?
本文介绍了我怎样才能显示我的TextView的省略号如果是大于1行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下布局不工作:
<的LinearLayout
机器人:方向=横向
机器人:layout_width =match_parent
机器人:ID =@ + ID / experienceLayout
机器人:后台=#FFFFFF
机器人:layout_height =match_parent
机器人:以下属性来=6DP
机器人:paddingRight =6DP
机器人:paddingBottom会=6DP
机器人:paddingTop =6DP>
<的TextView
机器人:layout_weight =1
机器人:ID =@ + ID / experienceLabel
机器人:文本=体验
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#000000
机器人:layout_width =WRAP_CONTENT
机器人:TEXTSTYLE =黑体>
< / TextView的>
<的TextView
机器人:ID =@ + ID / experienceTextView
机器人:文本=TextView的
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#000000
机器人:layout_width =WRAP_CONTENT
机器人:ellipsize =结束
机器人:行=1
机器人:MAXLINES =1
机器人:单线=真
机器人:fadeScrollbars =假>
< / TextView的>
< / LinearLayout中>
解决方案
这是一个常见的问题。请尝试使用以下内容:
安卓scrollHorizontally =真
机器人:ellipsize =结束
机器人:MAXLINES =1
..............的scrollHorizontally是特制的酱汁,使得它的工作。
I have the following Layout which does not work:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:id="@+id/experienceLayout"
android:background="#ffffff"
android:layout_height="match_parent"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingBottom="6dp"
android:paddingTop="6dp">
<TextView
android:layout_weight="1"
android:id="@+id/experienceLabel"
android:text="Experience"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_width="wrap_content"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/experienceTextView"
android:text="TextView"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_width="wrap_content"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:fadeScrollbars="false">
</TextView>
</LinearLayout>
解决方案
This is a common problem. Try using the following:
android:scrollHorizontally="true"
android:ellipsize="end"
android:maxLines="1"
.............. the scrollHorizontally is the "special sauce" that makes it work.
这篇关于我怎样才能显示我的TextView的省略号如果是大于1行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文