ellipsize的使用

需求:
textview最多顯示四個字符,多餘四個就顯示 “…”
填坑:使用android:maxLength="4"是沒有效果的,
需要使用 android:maxEms="4"纔有效果,一定要加上android:singleLine=“true”

<TextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:ellipsize="end"
 android:maxEms="4"
 android:singleLine="true"
                    />

需求:最多顯示兩行,多餘就顯示 “…”

<TextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:ellipsize="end"
 android:maxLines="2" 
                    />
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章