我有一个textView如下:
<TextView
android:id="@+id/pointsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pointTextView"
android:ellipsize="start"
android:lines="2"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:text="this is a very very very very very very very very very very very very very very very very very very very very very long sentence." />
此处ellipsize="end"
工作正常,但当没有行不是1时,ellipsize="start"
不会变形。
如何在具有2个或更多行的TextView中使这个工作?
答案 0 :(得分:10)
如果您想将android:ellipsize="start"
与android:maxLines="2"
(多个)一起使用,那么它在Android中是不可能的(因为API级别1)。
如果setMaxLines(int)用于设置两行或更多行,则仅支持END和MARQUEE(其他椭圆化类型不会执行任何操作)。
请参阅文档here
答案 1 :(得分:0)
试试这个
<TextView
android:id="@+id/pointsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="start"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:maxLines="1"
android:text="Hello this is a very very very very very very very very very very very very very very very very very very very very very long sentence. "
/>
答案 2 :(得分:0)
尝试一下(android:singleLine =“ true”)
<TextView
android:id="@+id/pointsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="start"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:singleLine="true"
android:text="Hello this is a very very very very very very very very very very very very very very very very very very very very very long sentence. "
/>